NetBSD Problem Report #18257

Received: (qmail 21642 invoked by uid 605); 10 Sep 2002 18:22:02 -0000
Message-Id: <Pine.SOL.4.44.0209101909010.25305-100000@draco.cus.cam.ac.uk>
Date: Tue, 10 Sep 2002 19:21:59 +0100 (BST)
From: Ben Harris <bjh21@netbsd.org>
Sender: gnats-bugs-owner@netbsd.org
To: gnats-bugs@gnats.netbsd.org
Subject: POSIX.2-1992: ps(1)'s TIME column has the wrong format

>Number:         18257
>Category:       standards
>Synopsis:       POSIX.2-1992: ps(1)'s TIME column has the wrong format
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    standards-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 10 18:23:00 +0000 2002
>Closed-Date:    Sun Apr 22 19:53:02 +0000 2012
>Last-Modified:  Sun Apr 22 19:53:02 +0000 2012
>Originator:     Ben Harris
>Release:        1.5.2
>Organization:
>Environment:
System: NetBSD viking 1.5.2 NetBSD 1.5.2 (VIKING) #9: Sat May 11 12:39:15 BST 2002 bjh21@viking:/usr/src/sys/arch/macppc/compile/VIKING macppc

>Description:
The "TIME" column in ps's output is specified by IEEE Std 1003.2-1992, and
by IEEE Std 1003.1-2001 as containing:

# [dd-]hh:mm:ss
#
# where dd shall represent the number of days, hh the number of hours, mm
# the number of minutes, and ss the number of seconds. The dd field shall be
# a decimal integer. The hh, mm, and ss fields shall be two-digit decimal
# integers padded on the left with zeros.

<http://www.opengroup.org/onlinepubs/007904975/utilities/ps.html>

On NetBSD, though, the format appears to be hh:mm.ss, with hh not being
fixed-width

>How-To-Repeat:
$ ps -o time
      TIME
   0:00.16
   0:00.01
8590:30.81

>Fix:

>Release-Note:
>Audit-Trail:
From: Julian Djamil Fagir <gnrp@komkon2.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: standards/18257: POSIX.2-1992: ps(1)'s TIME column has the
 wrong format
Date: Tue, 14 Feb 2012 15:42:15 +0100

 --MP_/dbwTx/.nKTnAExi31fxRAl9
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline

 Hi,

 the attached patches should solve that issue.

 Though there's one issue: This patch introduces POSIX compliancy, but
 decreases precision. Before, you had the cputime measured in centiseconds,
 while POSIX requires it to be at most seconds.

 You could either introduce another keyword - e.g. pcputime or ptime (p for
 precision) to display them again - or dump this proposal and be non-posix
 compliant or dump the precision and be posix-compliant.

 Which is the way to go?

 Regards, Julian
 --MP_/dbwTx/.nKTnAExi31fxRAl9
 Content-Type: text/x-patch
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment; filename=extern.h.diff

 --- bin/ps/extern.h
 +++ bin/ps/extern.h
 @@ -76,10 +76,11 @@
  void	 pcpu(void *, VARENT *, int);
  void	 pmem(void *, VARENT *, int);
  void	 pnice(void *, VARENT *, int);
  void	 pri(void *, VARENT *, int);
  void	 printheader(void);
 +void	 printtime(void *, VARENT *, int, int);
  void	 putimeval(void *, VARENT *, int);
  void	 pvar(void *, VARENT *, int);
  void	 rgname(void *, VARENT *, int);
  void	 rssize(void *, VARENT *, int);
  void	 runame(void *, VARENT *, int);


 --MP_/dbwTx/.nKTnAExi31fxRAl9
 Content-Type: text/x-patch
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment; filename=print.c.diff

 --- bin/ps/print.c
 +++ bin/ps/print.c
 @@ -102,10 +102,12 @@

  static time_t now;

  #define	min(a,b)	((a) <= (b) ? (a) : (b))

 +#define PHOURS		0x01
 +
  static int
  iwidth(u_int64_t v)
  {
  	u_int64_t nlim, lim;
  	int w = 1;
 @@ -846,14 +848,29 @@
  }

  void
  elapsed(void *arg, VARENT *ve, int mode)
  {
 +	printtime(arg, ve, mode, 0);
 +}
 +
 +void
 +cputime(void *arg, VARENT *ve, int mode)
 +{
 +	printtime(arg, ve, mode, PHOURS);
 +}
 +
 +/* printmod defines whether we want to print the hours. POSIX specifies the
 + * cputime to be printed [dd-]hh:mm:ss, while the elapsed time should be printed
 + * as [[dd-]hh:]mm:ss. */
 +void
 +printtime(void *arg, VARENT *ve, int mode, int printmod)
 +{
  	struct kinfo_proc2 *k;
  	VAR *v;
  	int32_t origseconds, secs, mins, hours, days;
 -	int fmtlen, printed_something;
 +	int fmtlen;

  	k = arg;
  	v = ve->var;
  	if (k->p_uvalid == 0) {
  		origseconds = 0;
 @@ -886,58 +903,34 @@

  		if (origseconds > v->longestp) {
  			v->longestp = origseconds;

  			if (days > 0) {
 -				/* +9 for "-hh:mm:ss" */
 +				/* days+9 for "dd-hh:mm:ss" */
  				fmtlen = iwidth(days) + 9;
 -			} else if (hours > 0) {
 -				/* +6 for "mm:ss" */
 -				fmtlen = iwidth(hours) + 6;
 +			} else if (hours > 0 || printmod & PHOURS) {
 +				/* 8 for "hh:mm:ss" */
 +				fmtlen = 8;
  			} else {
 -				/* +3 for ":ss" */
 -				fmtlen = iwidth(mins) + 3;
 +				/* 5 for "mm:ss" */
 +				fmtlen = 5;
  			}

  			if (fmtlen > v->width)
  				v->width = fmtlen;
  		}
  	} else {
 -		printed_something = 0;
  		fmtlen = v->width;

 -		if (days > 0) {
 -			(void)printf("%*d", fmtlen - 9, days);
 -			printed_something = 1;
 -		} else if (fmtlen > 9) {
 -			(void)printf("%*s", fmtlen - 9, "");
 -		}
 -		if (fmtlen > 9)
 -			fmtlen = 9;
 -
 -		if (printed_something) {
 -			(void)printf("-%.*d", fmtlen - 7, hours);
 -			printed_something = 1;
 -		} else if (hours > 0) {
 -			(void)printf("%*d", fmtlen - 6, hours);
 -			printed_something = 1;
 -		} else if (fmtlen > 6) {
 -			(void)printf("%*s", fmtlen - 6, "");
 -		}
 -		if (fmtlen > 6)
 -			fmtlen = 6;
 -
 -		/* Don't need to set fmtlen or printed_something any more... */
 -		if (printed_something) {
 -			(void)printf(":%.*d", fmtlen - 4, mins);
 -		} else if (mins > 0) {
 -			(void)printf("%*d", fmtlen - 3, mins);
 -		} else if (fmtlen > 3) {
 -			(void)printf("%*s", fmtlen - 3, "0");
 -		}
 -
 -		(void)printf(":%.2d", secs);
 +		if (days > 0)
 +			(void)printf("%*d-%.2d:%.2d:%.2d", fmtlen - 9,
 +					days, hours, mins, secs);
 +		else if (hours > 0 || printmod & PHOURS)
 +			(void)printf("%*.2d:%.2d:%.2d", fmtlen - 6, hours,
 +					mins, secs);
 +		else
 +			(void)printf("%*.2d:%.2d", fmtlen - 3, mins, secs);
  	}
  }

  void
  wchan(void *arg, VARENT *ve, int mode)
 @@ -1010,64 +1003,10 @@
  	VAR *v;

  	l = arg;
  	v = ve->var;
  	intprintorsetwidth(v, l->l_cpuid, mode);
 -}
 -
 -void
 -cputime(void *arg, VARENT *ve, int mode)
 -{
 -	struct kinfo_proc2 *k;
 -	VAR *v;
 -	int32_t secs;
 -	int32_t psecs;	/* "parts" of a second. first micro, then centi */
 -	int fmtlen;
 -
 -	k = arg;
 -	v = ve->var;
 -
 -	/*
 -	 * This counts time spent handling interrupts.  We could
 -	 * fix this, but it is not 100% trivial (and interrupt
 -	 * time fractions only work on the sparc anyway).	XXX
 -	 */
 -	secs = k->p_rtime_sec;
 -	psecs = k->p_rtime_usec;
 -	if (sumrusage) {
 -		secs += k->p_uctime_sec;
 -		psecs += k->p_uctime_usec;
 -	}
 -	/*
 -	 * round and scale to 100's
 -	 */
 -	psecs = (psecs + 5000) / 10000;
 -	secs += psecs / 100;
 -	psecs = psecs % 100;
 -
 -	if (mode == WIDTHMODE) {
 -		/*
 -		 * Ugg, this is the only field where a value of 0 is longer
 -		 * than the column title.
 -		 * Use SECSPERMIN, because secs is divided by that when
 -		 * passed to iwidth().
 -		 */
 -		if (secs == 0)
 -			secs = SECSPERMIN;
 -
 -		if (secs > v->longestp) {
 -			v->longestp = secs;
 -			/* "+6" for the ":%02ld.%02ld" in the printf() below */
 -			fmtlen = iwidth(secs / SECSPERMIN) + 6;
 -			if (fmtlen > v->width)
 -				v->width = fmtlen;
 -		}
 -	} else {
 -		(void)printf("%*ld:%02ld.%02ld", v->width - 6,
 -		    (long)(secs / SECSPERMIN), (long)(secs % SECSPERMIN),
 -		    (long)psecs);
 -	}
  }

  double
  getpcpu(k)
  	const struct kinfo_proc2 *k;


 --MP_/dbwTx/.nKTnAExi31fxRAl9
 Content-Type: text/x-patch
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment; filename=ps.1.diff

 --- bin/ps/ps.1
 +++ bin/ps/ps.1
 @@ -637,11 +637,13 @@
  user name (from svuid)
  .It Ar tdev
  control terminal device number
  .It Ar time
  accumulated CPU time, user + system (alias
 -.Ar cputime )
 +.Ar cputime ) ,
 +in the form
 +.Li [dd-]hh:mm:ss
  .It Ar tpgid
  control terminal process group
  .Tn ID
  .It Ar tsess
  control terminal session pointer


 --MP_/dbwTx/.nKTnAExi31fxRAl9--

From: Matthias Drochner <M.Drochner@fz-juelich.de>
To: gnrp@komkon2.de
Cc: gnats-bugs@NetBSD.org
Subject: Re: standards/18257: POSIX.2-1992: ps(1)'s TIME column has the wrong 
 format
Date: Tue, 14 Feb 2012 17:01:06 +0100

 > You could either introduce another keyword - e.g. pcputime or ptime (p fo=
 r
 > precision) to display them again - or dump this proposal and be non-posix
 > compliant or dump the precision and be posix-compliant.

 Imo it would make most sense to keep the traditional display if
 called with BSD syntax ("ps ax"), and be POSIX compliant if
 called with SYSV/POSIX syntax ("ps -ef").
 As long as we don't support POSIX at the command line there is
 no need to have the display strictly POSIX compliant.

 best regards
 Matthias



 ---------------------------------------------------------------------------=
 ----
 ---------------------------------------------------------------------------=
 ----
 Forschungszentrum Juelich GmbH
 52425 Juelich
 Sitz der Gesellschaft: Juelich
 Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
 Vorsitzender des Aufsichtsrats: MinDir Dr. Karl Eugen Huthmacher
 Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
 Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
 Prof. Dr. Sebastian M. Schmidt
 ---------------------------------------------------------------------------=
 ----
 ---------------------------------------------------------------------------=
 ----

 Kennen Sie schon unsere app? http://www.fz-juelich.de/app

From: Julian Fagir <gnrp@komkon2.de>
To: gnats-bugs@NetBSD.org
Cc: M.Drochner@fz-juelich.de
Subject: Re: standards/18257: POSIX.2-1992: ps(1)'s TIME column has the
 wrong  format
Date: Wed, 15 Feb 2012 04:40:56 +0100

 --MP_/igSg+bg1Z7cKc=gCCoJxKOX
 Content-Type: text/plain; charset=US-ASCII
 Content-Transfer-Encoding: 7bit
 Content-Disposition: inline

 Hi,

 > > You could either introduce another keyword - e.g. pcputime or ptime (p for
 > > precision) to display them again - or dump this proposal and be non-posix
 > > compliant or dump the precision and be posix-compliant.
 > 
 > Imo it would make most sense to keep the traditional display if
 > called with BSD syntax ("ps ax"), and be POSIX compliant if
 > called with SYSV/POSIX syntax ("ps -ef").
 > As long as we don't support POSIX at the command line there is
 > no need to have the display strictly POSIX compliant.
 ok, so what about the attached patches?
 They have [[dd-]hh:]mm:ss for etime in any case, [hh:]mm:ss for time in POSIX
 case and [hh:]mm:ss.pp for time in BSD case.

 Regards, Julian
 --MP_/igSg+bg1Z7cKc=gCCoJxKOX
 Content-Type: text/x-patch
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment; filename=extern.h.diff

 --- bin/ps/extern.h
 +++ bin/ps/extern.h
 @@ -38,10 +38,11 @@

  extern double ccpu;
  extern int eval, fscale, mempages, nlistread, rawcpu, maxslp, uspace;
  extern int sumrusage, termwidth, totwidth;
  extern int needenv, needcomm, commandonly;
 +extern int bsdpsopts;
  extern uid_t myuid;
  extern kvm_t *kd;
  extern VAR var[];
  extern VARLIST displaylist;
  extern VARLIST sortlist;
 @@ -76,10 +77,11 @@
  void	 pcpu(void *, VARENT *, int);
  void	 pmem(void *, VARENT *, int);
  void	 pnice(void *, VARENT *, int);
  void	 pri(void *, VARENT *, int);
  void	 printheader(void);
 +void	 printtime(int, int, int, int, int, int, int);
  void	 putimeval(void *, VARENT *, int);
  void	 pvar(void *, VARENT *, int);
  void	 rgname(void *, VARENT *, int);
  void	 rssize(void *, VARENT *, int);
  void	 runame(void *, VARENT *, int);
 @@ -94,5 +96,6 @@
  void	 ucomm(void *, VARENT *, int);
  void	 uname(void *, VARENT *, int);
  void	 uvar(void *, VARENT *, int);
  void	 vsize(void *, VARENT *, int);
  void	 wchan(void *, VARENT *, int);
 +int	 widthtime(int, int, int, int, int, int);


 --MP_/igSg+bg1Z7cKc=gCCoJxKOX
 Content-Type: text/x-patch
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment; filename=print.c.diff

 --- bin/ps/print.c
 +++ bin/ps/print.c
 @@ -102,10 +102,12 @@

  static time_t now;

  #define	min(a,b)	((a) <= (b) ? (a) : (b))

 +#define PHOURS		0x01
 +
  static int
  iwidth(u_int64_t v)
  {
  	u_int64_t nlim, lim;
  	int w = 1;
 @@ -846,14 +848,14 @@
  }

  void
  elapsed(void *arg, VARENT *ve, int mode)
  {
 +	int32_t origseconds, secs, mins, hours, days;
  	struct kinfo_proc2 *k;
  	VAR *v;
 -	int32_t origseconds, secs, mins, hours, days;
 -	int fmtlen, printed_something;
 +	int fmtlen;

  	k = arg;
  	v = ve->var;
  	if (k->p_uvalid == 0) {
  		origseconds = 0;
 @@ -878,66 +880,122 @@
  	mins %= MINSPERHOUR;
  	days = hours / HOURSPERDAY;
  	hours %= HOURSPERDAY;

  	if (mode == WIDTHMODE) {
 -		if (origseconds == 0)
 -			/* non-zero so fmtlen is calculated at least once */
 -			origseconds = 1;
 -
  		if (origseconds > v->longestp) {
  			v->longestp = origseconds;
 -
 -			if (days > 0) {
 -				/* +9 for "-hh:mm:ss" */
 -				fmtlen = iwidth(days) + 9;
 -			} else if (hours > 0) {
 -				/* +6 for "mm:ss" */
 -				fmtlen = iwidth(hours) + 6;
 -			} else {
 -				/* +3 for ":ss" */
 -				fmtlen = iwidth(mins) + 3;
 -			}
 -
 +			fmtlen = widthtime(days, hours, mins, secs, 0, 0);
 +			if (fmtlen > v->width)
 +				v->width = fmtlen;
 +		}
 +	} else {
 +		(void)printtime(days, hours, mins, secs, 0, v->width, 0);
 +	}
 +}
 +
 +void
 +cputime(void *arg, VARENT *ve, int mode)
 +{
 +	int32_t psecs, secs, mins, hours, days;
 +	struct kinfo_proc2 *k;
 +	VAR *v;
 +	int fmtlen;
 +
 +	k = arg;
 +	v = ve->var;
 +	/*
 +	 * This counts time spent handling interrupts.  We could
 +	 * fix this, but it is not 100% trivial (and interrupt
 +	 * time fractions only work on the sparc anyway).       XXX
 +	 */
 +	secs = k->p_rtime_sec;
 +	psecs = k->p_rtime_usec;
 +	if (sumrusage) {
 +	        secs += k->p_uctime_sec;
 +	        psecs += k->p_uctime_usec;
 +	}
 +	/*
 +	 * round and scale to 100's
 +	 */
 +	psecs = (psecs + 5000) / 10000;
 +	secs += psecs / 100;
 +	psecs = psecs % 100;
 +
 +	mins = secs / SECSPERMIN;
 +	secs %= SECSPERMIN;
 +	hours = mins / MINSPERHOUR;
 +	mins %= MINSPERHOUR;
 +	days = hours / HOURSPERDAY;
 +	hours %= HOURSPERDAY;
 +
 +	if (mode == WIDTHMODE) {
 +		if (secs > v->longestp) {
 +			v->longestp = secs;
 +			fmtlen = widthtime(days, hours, mins, secs, psecs, 
 +					PHOURS);
  			if (fmtlen > v->width)
  				v->width = fmtlen;
  		}
  	} else {
 -		printed_something = 0;
 -		fmtlen = v->width;
 -
 -		if (days > 0) {
 -			(void)printf("%*d", fmtlen - 9, days);
 -			printed_something = 1;
 -		} else if (fmtlen > 9) {
 -			(void)printf("%*s", fmtlen - 9, "");
 -		}
 -		if (fmtlen > 9)
 -			fmtlen = 9;
 -
 -		if (printed_something) {
 -			(void)printf("-%.*d", fmtlen - 7, hours);
 -			printed_something = 1;
 -		} else if (hours > 0) {
 -			(void)printf("%*d", fmtlen - 6, hours);
 -			printed_something = 1;
 -		} else if (fmtlen > 6) {
 -			(void)printf("%*s", fmtlen - 6, "");
 -		}
 -		if (fmtlen > 6)
 -			fmtlen = 6;
 -
 -		/* Don't need to set fmtlen or printed_something any more... */
 -		if (printed_something) {
 -			(void)printf(":%.*d", fmtlen - 4, mins);
 -		} else if (mins > 0) {
 -			(void)printf("%*d", fmtlen - 3, mins);
 -		} else if (fmtlen > 3) {
 -			(void)printf("%*s", fmtlen - 3, "0");
 -		}
 -
 -		(void)printf(":%.2d", secs);
 +		(void)printtime(days, hours, mins, secs, psecs, v->width, PHOURS);
 +	}
 +}
 +
 +/*
 + * We have three different outputs:
 + *   1. BSD options time:
 + *      hh:mm:ss.pp
 + *   2. POSIX options time:
 + *      [dd-]hh:mm:ss
 + *   3. BSD and POSIX options etime:
 + *      [[dd-]hh:]mm:ss
 + */
 +int
 +widthtime(int days, int hours, int mins, int secs, int psecs, int printmod)
 +{
 +	int fmtlen;
 +
 +	if (bsdpsopts && (printmod & PHOURS)) { /* BSD opts time */
 +		if (hours > 0)
 +			fmtlen = iwidth(hours + days * HOURSPERDAY) + 9;
 +		else
 +			fmtlen = iwidth(mins) + 6;
 +	} else { /* Any opts etime + POSIX opts time */
 +		if (days > 0)
 +			fmtlen = iwidth(days) + 9;
 +		else if (hours > 0 || (printmod & PHOURS)) /* POSIX opts time */
 +			fmtlen = 8;
 +		else
 +			fmtlen = 5;
 +	}
 +
 +	return fmtlen;
 +}
 +
 +void
 +printtime(int days, int hours, int mins, int secs, int psecs, int fmtlen,
 +		int printmod)
 +{
 +	if (bsdpsopts && (printmod & PHOURS)) { /* BSD opts time */
 +		if (hours > 0)
 +			(void)printf("%*d:%.2d:%.2d.%.2d", fmtlen - 9,
 +					hours + days * HOURSPERDAY,
 +					mins, secs, psecs);
 +		else
 +			(void)printf("%*d:%.2d.%.2d", fmtlen - 6, mins,
 +					secs, psecs);
 +	} else { /* Any opts etime + POSIX opts time */
 +		if (days > 0)
 +			(void)printf("%*d-%.2d:%.2d:%.2d", fmtlen - 9,
 +					days, hours, mins, secs);
 +		else if (hours > 0 || printmod & PHOURS) /* POSIX opts time */
 +			(void)printf("%*.2d:%.2d:%.2d", fmtlen - 6,
 +					hours, mins, secs);
 +		else
 +			(void)printf("%*.2d:%.2d", fmtlen - 3, mins,
 +					secs);
  	}
  }

  void
  wchan(void *arg, VARENT *ve, int mode)
 @@ -1010,64 +1068,10 @@
  	VAR *v;

  	l = arg;
  	v = ve->var;
  	intprintorsetwidth(v, l->l_cpuid, mode);
 -}
 -
 -void
 -cputime(void *arg, VARENT *ve, int mode)
 -{
 -	struct kinfo_proc2 *k;
 -	VAR *v;
 -	int32_t secs;
 -	int32_t psecs;	/* "parts" of a second. first micro, then centi */
 -	int fmtlen;
 -
 -	k = arg;
 -	v = ve->var;
 -
 -	/*
 -	 * This counts time spent handling interrupts.  We could
 -	 * fix this, but it is not 100% trivial (and interrupt
 -	 * time fractions only work on the sparc anyway).	XXX
 -	 */
 -	secs = k->p_rtime_sec;
 -	psecs = k->p_rtime_usec;
 -	if (sumrusage) {
 -		secs += k->p_uctime_sec;
 -		psecs += k->p_uctime_usec;
 -	}
 -	/*
 -	 * round and scale to 100's
 -	 */
 -	psecs = (psecs + 5000) / 10000;
 -	secs += psecs / 100;
 -	psecs = psecs % 100;
 -
 -	if (mode == WIDTHMODE) {
 -		/*
 -		 * Ugg, this is the only field where a value of 0 is longer
 -		 * than the column title.
 -		 * Use SECSPERMIN, because secs is divided by that when
 -		 * passed to iwidth().
 -		 */
 -		if (secs == 0)
 -			secs = SECSPERMIN;
 -
 -		if (secs > v->longestp) {
 -			v->longestp = secs;
 -			/* "+6" for the ":%02ld.%02ld" in the printf() below */
 -			fmtlen = iwidth(secs / SECSPERMIN) + 6;
 -			if (fmtlen > v->width)
 -				v->width = fmtlen;
 -		}
 -	} else {
 -		(void)printf("%*ld:%02ld.%02ld", v->width - 6,
 -		    (long)(secs / SECSPERMIN), (long)(secs % SECSPERMIN),
 -		    (long)psecs);
 -	}
  }

  double
  getpcpu(k)
  	const struct kinfo_proc2 *k;


 --MP_/igSg+bg1Z7cKc=gCCoJxKOX
 Content-Type: text/x-patch
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment; filename=ps.1.diff

 --- bin/ps/ps.1
 +++ bin/ps/ps.1
 @@ -638,10 +638,15 @@
  .It Ar tdev
  control terminal device number
  .It Ar time
  accumulated CPU time, user + system (alias
  .Ar cputime )
 +in the format
 +.Li [dd-]hh:mm:ss
 +if you use POSIX-style options or
 +.Li [hh:]mm:ss.pp
 +if you use BSD-style options
  .It Ar tpgid
  control terminal process group
  .Tn ID
  .It Ar tsess
  control terminal session pointer


 --MP_/igSg+bg1Z7cKc=gCCoJxKOX
 Content-Type: text/x-patch
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment; filename=ps.c.diff

 --- bin/ps/ps.c
 +++ bin/ps/ps.c
 @@ -109,10 +109,11 @@

  struct kinfo_proc2 *kinfo;
  struct varlist displaylist = SIMPLEQ_HEAD_INITIALIZER(displaylist);
  struct varlist sortlist = SIMPLEQ_HEAD_INITIALIZER(sortlist);

 +int	bsdpsopts;		/* set to 1 when using BSD options */
  int	eval;			/* exit value */
  int	rawcpu;			/* -C */
  int	sumrusage;		/* -S */
  int	termwidth;		/* width of screen (0 == infinity) */
  int	totwidth;		/* calculated width of requested variables */
 @@ -696,12 +697,14 @@
  	if ((newopts = ns = malloc(len + 3)) == NULL)
  		err(1, NULL);
  	/*
  	 * options begin with '-'
  	 */
 -	if (*s != '-')
 +	if (*s != '-') {
  		*ns++ = '-';	/* add option flag */
 +		bsdpsopts = 1;
 +	}
  	/*
  	 * gaze to end of argv[1]
  	 */
  	cp = s + len - 1;
  	/*


 --MP_/igSg+bg1Z7cKc=gCCoJxKOX--

From: Alan Barrett <apb@cequrux.com>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: standards/18257: POSIX.2-1992: ps(1)'s TIME column has the wrong
 format
Date: Wed, 15 Feb 2012 07:28:43 +0200

 On Wed, 15 Feb 2012, Julian Fagir wrote:
 >  .It Ar time
 >  accumulated CPU time, user + system (alias
 >  .Ar cputime )
 > +in the format
 > +.Li [dd-]hh:mm:ss
 > +if you use POSIX-style options or
 > +.Li [hh:]mm:ss.pp
 > +if you use BSD-style options

 Where are POSIX-style options and BSD-style options defined?

 I don't mind adding days, like "[ddd-]HH:MM:SS.ss", maybe even 
 breaking compatibility for scripts that parse the output from ps, 
 but why do we have to be compatible with a stupid POSIX rule about 
 "no fractional seconds"?

 Looking at the implemetation, it appears that the output from "ps 
 ax" and "ps -ax" will be different.  I really dislike this.  If we 
 do any sort of magic format switching, then I'd like a better way, 
 and whatever we do the man page should contain a discussion of the 
 tradeoffs.

 --apb (Alan Barrett)

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: standards/18257: POSIX.2-1992: ps(1)'s TIME column has the wrong
 format
Date: Thu, 16 Feb 2012 09:50:54 +0000

 On Wed, Feb 15, 2012 at 05:30:07AM +0000, Alan Barrett wrote:
  >  Looking at the implemetation, it appears that the output from "ps 
  >  ax" and "ps -ax" will be different.  I really dislike this.  If we 
  >  do any sort of magic format switching, then I'd like a better way, 
  >  and whatever we do the man page should contain a discussion of the 
  >  tradeoffs.

 Since POSIX chose to bless System V ps and we have a Berkeley ps,
 there's not much point in expecting (or attempting to implement) exact
 conformance.

 If there's a real reason to want a System V ps (as opposed to
 standards wanking) it should be a separate binary. Otherwise you end
 up with horrors like linux's procps.

 -- 
 David A. Holland
 dholland@netbsd.org

From: Klaus Klein <kleink@kleink.org>
To: gnats-bugs@NetBSD.org
Cc: standards-manager@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: standards/18257: POSIX.2-1992: ps(1)'s TIME column has the wrong
 format
Date: Mon, 5 Mar 2012 21:22:31 +0100

 On Thu, Feb 16, 2012 at 09:55:02AM +0000, David Holland wrote:
 > The following reply was made to PR standards/18257; it has been noted by GNATS.
 > 
 > From: David Holland <dholland-bugs@netbsd.org>
 > To: gnats-bugs@NetBSD.org
 > Cc: 
 > Subject: Re: standards/18257: POSIX.2-1992: ps(1)'s TIME column has the wrong
 >  format
 > Date: Thu, 16 Feb 2012 09:50:54 +0000
 > 
 >  On Wed, Feb 15, 2012 at 05:30:07AM +0000, Alan Barrett wrote:
 >   >  Looking at the implemetation, it appears that the output from "ps 
 >   >  ax" and "ps -ax" will be different.  I really dislike this.  If we 
 >   >  do any sort of magic format switching, then I'd like a better way, 
 >   >  and whatever we do the man page should contain a discussion of the 
 >   >  tradeoffs.
 >  
 >  Since POSIX chose to bless System V ps and we have a Berkeley ps,
 >  there's not much point in expecting (or attempting to implement) exact
 >  conformance.
 >  
 >  If there's a real reason to want a System V ps (as opposed to
 >  standards wanking) it should be a separate binary. Otherwise you end
 >  up with horrors like linux's procps.

 I've suggested using _CS_PATH for this before, _if_ someone really
 cares sufficiently about having a System-V-ps-done-right in the
 system to implement it.


 - Klaus

State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 22 Apr 2012 19:53:02 +0000
State-Changed-Why:
System V ps considered harmful to sanity. If someone wants it badly enough
to implement it properly, let's do so; in the meantime, there's no point
worrying about this issue.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.