Subject: Re: standards/17497: POSIX.1-2001: ps -A not supported
To: Ben Harris <>
From: Simon Burge <>
List: netbsd-bugs
Date: 07/07/2002 20:55:52
On Sun, Jul 07, 2002 at 08:07:19PM +1000, Simon Burge wrote:

> On Sun, Jul 07, 2002 at 11:02:02AM +0100, Ben Harris wrote:
> > That's why I said "POSIX".  The POSIX.1-2001 version of ps (i.e. IEEE
> > 1003.1-2001 without the XSI option) should't have any conflicts with our
> > one.  Unfortunately, because of the way the shading is done in
> > 1003.1-2001, it's a bit hard to see, but the POSIX synopsis boils down to:
> > 
> > ps [-aA] [-G grouplist] [-o format] [-p proclist] [-t termlist]
> >    [-U userlist]
> Ok, so we don't do -A and -G, and we don't support lists for -{p,t,U}.
> That's not too bad...

The following patch adds -A and -G (again, for a single value and not a
list).  I'll commit that soonish.  We need to come up with some words
for the "STANDARDS" section of the manual page.  There's some variations
looking at other man pages.  For cat(1):

     The cat utility is expected to conform to the IEEE Std 1003.2-1992
     (``POSIX.2'') specification.

     The flags [-benstv] are extensions to the specification.

For cp(1):

     The cp utility is expected to be IEEE Std 1003.2 (``POSIX.2'') compati-

For test(1):

     The test utility implements a superset of the IEEE Std 1003.2
     (``POSIX.2'') specification.

Also, according to SUSv3, -U is for "real user ID numbers or login
names" whereas we use it for the effective user ID, so we'd have to
document that difference.

Something like:

    The ps utility mostly implements a superset of the IEEE Std
    1003.1-2001 (``POSIX.2'') specification.  The -U option to
    the ps utility uses the effective user ID instead of the real
    user ID, and the -G, -p, -t, and -U options handle only a
    single argument instead of a list.

sound ok?

Simon Burge                                   <>
NetBSD Development, Support and Service:

Index: ps.1
RCS file: /cvsroot/basesrc/bin/ps/ps.1,v
retrieving revision 1.54
diff -d -p -u -r1.54 ps.1
--- ps.1	2002/06/19 08:11:56	1.54
+++ ps.1	2002/07/07 10:46:59
@@ -41,8 +41,10 @@
 .Nd process status
 .Nm ""
-.Op Fl acCehjlmrSTuvwx
+.Op Fl aAcCehjlmrSTuvwx
 .Bk -words
+.Op Fl G Ar gid
 .Op Fl M Ar core
 .Bk -words
@@ -90,7 +92,10 @@ state, and associated command.
 The options are as follows:
 .Bl -tag -width indent
 .It Fl a
-Display information about other users' processes as well as your own.
+Display information about other users' processes that have controlling
+terminals as well as your own.
+.It Fl A
+Display information about all processes.
 .It Fl c
 Do not display full command with arguments, but only the
 executable name.
@@ -105,6 +110,10 @@ no effect).
 .It Fl e
 Display the environment as well.  The environment for other
 users' processes can only be displayed by the super-user.
+.It Fl G
+Displays processes whose real gid has been given to the
+.Fl G
 .It Fl h
 Repeat the information header as often as necessary to guarantee one
 header per page of information.
Index: ps.c
RCS file: /cvsroot/basesrc/bin/ps/ps.c,v
retrieving revision 1.47
diff -d -p -u -r1.47 ps.c
--- ps.c	2002/06/19 08:11:56	1.47
+++ ps.c	2002/07/07 10:46:59
@@ -112,7 +112,7 @@ __RCSID("$NetBSD: ps.c,v 1.47 2002/06/19
  * ARGOPTS must contain all option characters that take arguments
  * (except for 't'!) - it is used in kludge_oldps_options()
-#define	GETOPTSTR	"acCeghjKLlM:mN:O:o:p:rSTt:U:uvW:wx"
+#define	GETOPTSTR	"aAcCegG:hjKLlM:mN:O:o:p:rSTt:U:uvW:wx"
 #define	ARGOPTS		"MNOopUW"
 struct kinfo_proc2 *kinfo;
@@ -181,6 +181,11 @@ main(argc, argv)
 			what = KERN_PROC_ALL;
 			flag = 0;
+		case 'A':
+			what = KERN_PROC_ALL;
+			flag = 0;
+			xflg = 1;
+			break;
 		case 'c':
 			commandonly = 1;
@@ -192,6 +197,11 @@ main(argc, argv)
 		case 'g':
 			break;			/* no-op */
+		case 'G':
+			what = KERN_PROC_RGID;
+			flag = atol(optarg);
+			xflg = 1;
+			break;
 		case 'h':
 			prtheader = ws.ws_row > 5 ? ws.ws_row : 22;