Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2006/0410/8

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


ps: add -r flag (sorry)
 [rsc] --rw-rw-r-- M 628694 glenda sys 2783 Apr 10 12:31 sys/src/cmd/ps.c
	/n/sourcesdump/2006/0410/plan9/sys/src/cmd/ps.c:9,14 - 
	/n/sourcesdump/2006/0411/plan9/sys/src/cmd/ps.c:9,15
	  Biobuf	bout;
	  int	pflag;
	  int	aflag;
	+ int	rflag;
	  
	  void
	  main(int argc, char *argv[])
	/n/sourcesdump/2006/0410/plan9/sys/src/cmd/ps.c:24,29 - 
	/n/sourcesdump/2006/0411/plan9/sys/src/cmd/ps.c:25,33
	  	case 'p':
	  		pflag++;
	  		break;
	+ 	case 'r':
	+ 		rflag++;
	+ 		break;
	  	} ARGEND;
	  	Binit(&bout, 1, OWRITE);
	  	if(chdir("/proc")==-1)
	/n/sourcesdump/2006/0410/plan9/sys/src/cmd/ps.c:54,62 - 
	/n/sourcesdump/2006/0411/plan9/sys/src/cmd/ps.c:58,66
	  void
	  ps(char *s)
	  {
	- 	ulong utime, stime, size;
	+ 	ulong utime, stime, rtime, size;
	  	int argc, basepri, fd, i, n, pri;
	- 	char args[256], *argv[16], buf[64], pbuf[8], status[4096];
	+ 	char args[256], *argv[16], buf[64], pbuf[8], rbuf[20], rbuf1[20], status[4096];
	  
	  	sprint(buf, "%s/status", s);
	  	fd = open(buf, OREAD);
	/n/sourcesdump/2006/0410/plan9/sys/src/cmd/ps.c:83,88 - 
	/n/sourcesdump/2006/0411/plan9/sys/src/cmd/ps.c:87,93
	  	 */
	  	utime = strtoul(argv[3], 0, 0)/1000;
	  	stime = strtoul(argv[4], 0, 0)/1000;
	+ 	rtime = strtoul(argv[5], 0, 0)/1000;
	  	size  = strtoul(argv[9], 0, 0);
	  	if(pflag){
	  		basepri = strtoul(argv[10], 0, 0);
	/n/sourcesdump/2006/0410/plan9/sys/src/cmd/ps.c:90,98 - 
	/n/sourcesdump/2006/0411/plan9/sys/src/cmd/ps.c:95,116
	  		sprint(pbuf, " %2d %2d", basepri, pri);
	  	} else
	  		pbuf[0] = 0;
	- 	Bprint(&bout, "%-10s %8s %4lud:%.2lud %3lud:%.2lud%s %7ludK %-8.8s ",
	+ 
	+ 	if(rflag){
	+ 		if(rtime >= 86400)
	+ 			sprint(rbuf, " %lud:%02lud:%02lud:%02lud", rtime/86400, (rtime/3600)%24, (rtime/60)%60, rtime%60);
	+ 		else if(rtime >= 3600)
	+ 			sprint(rbuf, " %lud:%02lud:%02lud", rtime/3600, (rtime/60)%60, rtime%60);
	+ 		else
	+ 			sprint(rbuf, " %lud:%02lud", rtime/60, rtime%60);
	+ 		sprint(rbuf1, "%12s", rbuf);
	+ 	}else
	+ 		rbuf1[0] = 0;
	+ 
	+ 	Bprint(&bout, "%-10s %8s%s %4lud:%.2lud %3lud:%.2lud %s %7ludK %-8.8s ",
	  			argv[1],
	  			s,
	+ 			rbuf1,
	  			utime/60, utime%60,
	  			stime/60, stime%60,
	  			pbuf,
 [rsc] --rw-rw-r-- M 628694 glenda sys 1722 Apr 10 12:31 sys/man/1/ps
	/n/sourcesdump/2006/0410/plan9/sys/man/1/ps:4,15 - 
	/n/sourcesdump/2006/0411/plan9/sys/man/1/ps:4,15
	  .SH SYNOPSIS
	  .B ps
	  [
	- .B -pa
	+ .B -apr
	  ]
	  .PP
	  .B psu
	  [
	- .B -pa
	+ .B -apr
	  ]
	  [
	  .I user
	/n/sourcesdump/2006/0410/plan9/sys/man/1/ps:82,92 - 
	/n/sourcesdump/2006/0411/plan9/sys/man/1/ps:82,98
	  .IR resource .
	  .PD
	  .PP
	- With the
	+ The
	+ .B -r
	+ flag causes
	+ .I ps
	+ to print, before the user time, the elapsed real time for the process.
	+ .PP
	+ The
	  .B -p
	- flag,
	+ flag causes
	  .I ps
	- also prints, after the system time, the baseline and current priorities of each process.
	+ to print, after the system time, the baseline and current priorities of each process.
	  .PP
	  The
	  .B -a


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].