tuse os-provided state strings - plan9port - [fork] Plan 9 from user space (HTM) git clone git://src.adamsgaard.dk/plan9port (DIR) Log (DIR) Files (DIR) Refs (DIR) README (DIR) LICENSE --- (DIR) commit c57a7371ba73df79aecdf64addf4254ef61e6b29 (DIR) parent 88f2c3b0b7cd18669e63d990ee15e8e6486c407d (HTM) Author: rsc <devnull@localhost> Date: Mon, 19 Apr 2004 05:51:59 +0000 use os-provided state strings Diffstat: M bin/ps | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) --- (DIR) diff --git a/bin/ps b/bin/ps t@@ -23,8 +23,10 @@ BEGIN{ state["X"] = "Moribund"; } -function statestr(s) +function statestr(s, wchan) { + if(wchan != s && wchan != "?") + return wchan; t = state[substr(s, 1, 1)]; if(t == "") return s; t@@ -43,6 +45,7 @@ function statestr(s) cputime=$i; i++ mem=$i; i++ stat=$i; i++ + wchan=$i; i++ cmd=$i; i++ if(ENVIRON["all"] == "yes"){ for(; i<=NF; i++) t@@ -62,17 +65,17 @@ function statestr(s) sub(/:..$/, "", start); } printf("%-8s %11d %8s %8s %8dK %-8s %s\n", - user, pid, start, cputime, mem, statestr(stat), cmd); + user, pid, start, cputime, mem, statestr(stat, wchan), cmd); } ! case "${SYSNAME:-`uname`}" in SunOS) - /bin/ps -aA -o 'user,pid,stime,time,vsz,s,args' | sed 1d | + /bin/ps -aA -o 'user,pid,stime,time,vsz,s,s,args' | sed 1d | nawk -f /tmp/awk.xxx$$ | sort -n +1 ;; *) - /bin/ps -axww -o 'user,pid,start,time,vsz,stat,command' | sed 1d | + /bin/ps -axww -o 'user,pid,start,time,vsz,stat,wchan,command' | sed 1d | awk -f /tmp/awk.xxx$$ | sort -n +1 ;; esac