ref: dc25c70249533d18279555eab7b1bd22af170e82
parent: 1159f1e54f376cbd8db7ea9387818c2c10f79627
author: cinap_lenrek <[email protected]>
date: Wed Aug 1 22:47:18 EDT 2012
ps -n print note group
--- a/sys/src/cmd/ps.c
+++ b/sys/src/cmd/ps.c
@@ -9,6 +9,7 @@
Biobuf bout;
int pflag;
int aflag;
+int nflag;
int rflag;
void
@@ -25,6 +26,9 @@
case 'p':
pflag++;
break;
+ case 'n':
+ nflag++;
+ break;
case 'r':
rflag++;
break;
@@ -60,7 +64,7 @@
{
ulong utime, stime, rtime, size;
int argc, basepri, fd, i, n, pri;
- char args[256], *argv[16], buf[64], pbuf[8], rbuf[20], rbuf1[20], status[4096];
+ char args[256], *argv[16], buf[64], nbuf[13], pbuf[8], rbuf[20], rbuf1[20], status[4096];
sprint(buf, "%s/status", s);
fd = open(buf, OREAD);
@@ -89,6 +93,19 @@
stime = strtoul(argv[4], 0, 0)/1000;
rtime = strtoul(argv[5], 0, 0)/1000;
size = strtoul(argv[9], 0, 0);
+ if(nflag){
+ snprint(nbuf, sizeof nbuf, " %8s", "?");
+ sprint(buf, "%s/noteid", s);
+ fd = open(buf, OREAD);
+ if(fd >= 0) {
+ n = read(fd, buf, sizeof buf-1);
+ close(fd);
+ if(n > 0)
+ snprint(nbuf, sizeof nbuf, " %7ud", atoi(buf));
+ }
+ }else
+ nbuf[0] = 0;
+
if(pflag){
basepri = strtoul(argv[10], 0, 0);
pri = strtoul(argv[11], 0, 0);
@@ -107,9 +124,10 @@
}else
rbuf1[0] = 0;
- Bprint(&bout, "%-10s %8s%s %4lud:%.2lud %3lud:%.2lud %s %7ludK %-8.8s ",
+ Bprint(&bout, "%-10s %8s%s%s %4lud:%.2lud %3lud:%.2lud %s %7ludK %-8.8s ",
argv[1],
s,
+ nbuf,
rbuf1,
utime/60, utime%60,
stime/60, stime%60,