From owner-freebsd-standards Sun Jun 9 12:50:13 2002 Delivered-To: freebsd-standards@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 7C8BE37B408; Sun, 9 Jun 2002 12:50:09 -0700 (PDT) Received: (from mike@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g59Jo9106335; Sun, 9 Jun 2002 12:50:09 -0700 (PDT) (envelope-from mike) Date: Sun, 9 Jun 2002 12:50:09 -0700 (PDT) From: Message-Id: <200206091950.g59Jo9106335@freefall.freebsd.org> To: clefevre@citeweb.net, mike@FreeBSD.org, standards@FreeBSD.org Subject: Re: bin/22210: typeof(passwd->pw_gid) != typeof(group->gr_gid) Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Synopsis: typeof(passwd->pw_gid) != typeof(group->gr_gid) State-Changed-From-To: open->closed State-Changed-By: mike State-Changed-When: Sun Jun 9 12:47:25 PDT 2002 State-Changed-Why: I've taken care of the namespace problems. http://www.freebsd.org/cgi/query-pr.cgi?pr=22210 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Jun 10 20:11: 2 2002 Delivered-To: freebsd-standards@freebsd.org Received: from smtp.noos.fr (racine.noos.net [212.198.2.71]) by hub.freebsd.org (Postfix) with ESMTP id 1E9EA37B407 for ; Mon, 10 Jun 2002 20:09:10 -0700 (PDT) Received: (qmail 8900962 invoked by uid 0); 11 Jun 2002 03:08:59 -0000 Received: from unknown (HELO gits.gits.dyndns.org) ([212.198.230.194]) (envelope-sender ) by 212.198.2.71 (qmail-ldap-1.03) with SMTP for ; 11 Jun 2002 03:08:59 -0000 Received: from gits.gits.dyndns.org (fw8edi2kltfamt7h@localhost [127.0.0.1]) by gits.gits.dyndns.org (8.12.3/8.12.3) with ESMTP id g5B38wa6016571; Tue, 11 Jun 2002 05:08:58 +0200 (CEST) (envelope-from root@gits.dyndns.org) Received: (from root@localhost) by gits.gits.dyndns.org (8.12.3/8.12.3/Submit) id g5B38wmA016570; Tue, 11 Jun 2002 05:08:58 +0200 (CEST) (envelope-from root) Date: Tue, 11 Jun 2002 05:08:57 +0200 From: Cyrille Lefevre To: "J. Mallett" Cc: standards@FreeBSD.org Subject: Re: cvs commit: www/en/projects/c99 index.sgml Message-ID: <20020611030857.GB14401@gits.dyndns.org> References: <200206070217.g572HH584853@freefall.freebsd.org> <20020606194448.A23497@FreeBSD.ORG> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="/NkBOFFp2J2Af1nK" Content-Disposition: inline In-Reply-To: <20020606194448.A23497@FreeBSD.ORG> User-Agent: Mutt/1.3.99i Organization: ACME X-Face: V|+c;4!|B?E%BE^{E6);aI.[< List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --/NkBOFFp2J2Af1nK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jun 06, 2002 at 07:44:49PM -0700, J. Mallett wrote: > * From Mike Barcroft > > mike 2002/06/06 19:17:17 PDT > > > > Modified files: > > en/projects/c99 index.sgml > > Log: > > J. Mallett will be coordinating changes to ps(1). > > Which essentially means: If you have patches for ps(1) wrt SUSv3 conformance, > or want to discuss which options of ours should go in favor of SUSv3 ones that > conflict, which should be optional, etc., speak up. well, I'm a lot disapointed about your nomination while I ask for it last week. I suppose you get the maintainership of ps(1) because you are a commiter ? whatever, here is, in attachment, the current version of ps(1) I'm working on. PS : I've tryed to subscribe to this list twince w/o success, any ideas ? Cyrille. -- Cyrille Lefevre mailto:cyrille.lefevre@laposte.net --/NkBOFFp2J2Af1nK Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=NOTES ps compatible pre-BSD44, BSD44 and SUSV2 first of all, this code has been made last year and is based on -stable version of ps(1). since then, I never posted it before because it's conformance to SUSV2 (now SUSV3) needs to be checked. this need always to be done and I will do it w/in the next days (weeks?). in the meantime, I'll write a more detailled note about differences between BSD and SUSV3 ps(1). also, the manual would have to be updated to reflect the reallity (any volunteer ? :). old compilation flags : BACKWARD_COMPATIBILITY convert pre BSD44 options (w/o dash) to BSD44 ones. LAZY_PS enable option -f to show command line and environment information about swapped out processes else, the -f option is implied. new compilation flags : COMPAT_BSD44 be strictly compatible w/ BSD44 ps, else : * -p, -t and -U respectively accept a list of pids, ttys or users instead of a single one. * -t accept ttyXX in addition to /dev/ttyXX and XX. * -U also accept uids in addition of user names. * output is formated more intelligently when combining options such as -j, -l, -u and -v. format strings are combined instead of being concatenated. * -o keyword=header now works for aliased keywords, also, -o keyword= don't print an empty line anymore, if any. COMPAT_SUSV2 be compatible w/ SUSV2 ps if the SUSV2 environment variable has a non-zero value or if called as ps5. this may be overriden using the new -B (BSD) or -V (SUSV2) options. SUSV2 is automagically disabled when using pre BSD44 options. SUSV2 options are, in fact, almost the SYSV ones. here is the usage string : usage: ps [-AaBdefjl] [-C cmdlist] [-g pgrplist] [-G grouplist] [-o fmt] [-p pidlist] [-t ttylist] [-u userlist] [-U userlist] [-m core] [-n system] [-w swap] here are the new -o keywords w/ their BSD44 counterpart, if any, in parentheses : addr (paddr), args (command), c, comm (command), etime, group, l (state), rgroup and stime. and the ones which are affected when SUSV2 is enable : pri and time. NO_SWAP disable -W option since kvm(3) doesn't read swap for almost 10 years. also, single-linked tail queues have been converted to queue(3). --/NkBOFFp2J2Af1nK Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ps-stable.patch" Index: Makefile =================================================================== RCS file: /home/ncvs/src/bin/ps/Makefile,v retrieving revision 1.13 diff -u -r1.13 Makefile --- Makefile 17 Nov 1999 13:37:30 -0000 1.13 +++ Makefile 11 Jun 2002 03:02:38 -0000 @@ -9,7 +9,12 @@ # keep ps from being an unnecessary load # on large systems. # -CFLAGS+=-I${.CURDIR}/../../sys -DLAZY_PS +CFLAGS= -g +CFLAGS+= -I${.CURDIR}/../../sys +CFLAGS+= -DBACKWARD_COMPATIBILITY +CFLAGS+= -DLAZY_PS +# CFLAGS+= -DCOMPAT_BSD44 +CFLAGS+= -DCOMPAT_SUSV2 DPADD= ${LIBM} ${LIBKVM} LDADD= -lm -lkvm #BINGRP= kmem Index: extern.h =================================================================== RCS file: /home/ncvs/src/bin/ps/extern.h,v retrieving revision 1.9 diff -u -r1.9 extern.h --- extern.h 27 Aug 1999 23:14:50 -0000 1.9 +++ extern.h 5 Jun 2001 01:16:06 -0000 @@ -34,45 +34,61 @@ * $FreeBSD: src/bin/ps/extern.h,v 1.9 1999/08/27 23:14:50 peter Exp $ */ -struct kinfo; -struct nlist; -struct var; -struct varent; - extern fixpt_t ccpu; extern int eval, fscale, mempages, nlistread, rawcpu, cflag; extern int sumrusage, termwidth, totwidth; extern VAR var[]; -extern VARENT *vhead; +extern VARLIST varlist; + +#if defined(COMPAT_SUSV2) +extern int susv2; +#endif __BEGIN_DECLS void command __P((KINFO *, VARENT *)); void cputime __P((KINFO *, VARENT *)); int donlist __P((void)); +#if defined(COMPAT_SUSV2) +void etime __P((KINFO *, VARENT *)); +#endif void evar __P((KINFO *, VARENT *)); char *fmt_argv __P((char **, char *, int)); double getpcpu __P((KINFO *)); -double getpmem __P((KINFO *)); +#if defined(COMPAT_SUSV2) +void gname __P((KINFO *, VARENT *)); +int s_gname __P((KINFO *)); +#endif void logname __P((KINFO *, VARENT *)); void longtname __P((KINFO *, VARENT *)); void lstarted __P((KINFO *, VARENT *)); void maxrss __P((KINFO *, VARENT *)); -void nlisterr __P((struct nlist *)); void p_rssize __P((KINFO *, VARENT *)); void pagein __P((KINFO *, VARENT *)); -void parsefmt __P((char *)); +#if defined(COMPAT_BSD44) +void bsd_parsefmt __P((char *)); +#endif +#if defined (COMPAT_SUSV2) +void susv2_parsefmt __P((char *, char *)); +#endif void pcpu __P((KINFO *, VARENT *)); void pmem __P((KINFO *, VARENT *)); void pri __P((KINFO *, VARENT *)); -void rtprior __P((KINFO *, VARENT *)); void printheader __P((void)); void pvar __P((KINFO *, VARENT *)); +#if defined(COMPAT_SUSV2) +void rgname __P((KINFO *, VARENT *)); +int s_rgname __P((KINFO *)); +#endif void rssize __P((KINFO *, VARENT *)); +void rtprior __P((KINFO *, VARENT *)); void runame __P((KINFO *, VARENT *)); int s_runame __P((KINFO *)); void rvar __P((KINFO *, VARENT *)); void showkey __P((void)); void started __P((KINFO *, VARENT *)); +#if defined(COMPAT_SUSV2) +void stime __P((KINFO *, VARENT *)); +#endif void state __P((KINFO *, VARENT *)); void tdev __P((KINFO *, VARENT *)); void tname __P((KINFO *, VARENT *)); Index: fmt.c =================================================================== RCS file: /home/ncvs/src/bin/ps/fmt.c,v retrieving revision 1.14.2.1 diff -u -r1.14.2.1 fmt.c --- fmt.c 16 Mar 2002 01:15:11 -0000 1.14.2.1 +++ fmt.c 25 May 2002 17:11:04 -0000 @@ -32,23 +32,23 @@ */ #ifndef lint +#include #if 0 -static char sccsid[] = "@(#)fmt.c 8.4 (Berkeley) 4/15/94"; +__RCSID("@(#)fmt.c 8.4 (Berkeley) 4/15/94"); #endif -static const char rcsid[] = - "$FreeBSD: src/bin/ps/fmt.c,v 1.14.2.1 2002/03/16 01:15:11 mikeh Exp $"; +__FBSDID("$FreeBSD: src/bin/ps/fmt.c,v 1.14.2.1 2002/03/16 01:15:11 mikeh Exp $"); #endif /* not lint */ #include #include #include + #include #include #include #include #include #include -#include "ps.h" static char *cmdpart __P((char *)); static char *shquote __P((char **)); Index: keyword.c =================================================================== RCS file: /home/ncvs/src/bin/ps/keyword.c,v retrieving revision 1.24.2.2 diff -u -r1.24.2.2 keyword.c --- keyword.c 21 Sep 2001 04:49:23 -0000 1.24.2.2 +++ keyword.c 25 May 2002 17:15:04 -0000 @@ -32,11 +32,11 @@ */ #ifndef lint +#include #if 0 -static char sccsid[] = "@(#)keyword.c 8.5 (Berkeley) 4/2/94"; +__RCSID("@(#)keyword.c 8.5 (Berkeley) 4/2/94"); #else -static const char rcsid[] = - "$FreeBSD: src/bin/ps/keyword.c,v 1.24.2.2 2001/09/21 04:49:23 peter Exp $"; +__FBSDID("$FreeBSD: src/bin/ps/keyword.c,v 1.24.2.2 2001/09/21 04:49:23 peter Exp $"); #endif #endif /* not lint */ @@ -47,6 +47,7 @@ #include #include #include +#include #include #include @@ -58,8 +59,16 @@ #include "ps.h" -static VAR *findvar __P((char *)); -static int vcmp __P((const void *, const void *)); +#define FMTSEP ", \t\n" + +#if defined(COMPAT_BSD44) +static void bsd_parsefmt1 __P((char *, char *)); +#endif +#if defined(COMPAT_SUSV2) +static void susv2_parsefmt1 __P((char *, char *, char *)); +#endif +static VAR *findvar __P((char *, char *)); +static int vcmp __P((const void *, const void *)); #ifdef NOTINUSE int utime(), stime(), ixrss(), idrss(), isrss(); @@ -83,113 +92,156 @@ #define USERLEN UT_NAMESIZE VAR var[] = { - {"%cpu", "%CPU", NULL, 0, pcpu, NULL, 4}, - {"%mem", "%MEM", NULL, 0, pmem, NULL, 4}, - {"acflag", "ACFLG", - NULL, 0, pvar, NULL, 3, POFF(p_acflag), USHORT, "x"}, - {"acflg", "", "acflag"}, - {"blocked", "", "sigmask"}, - {"caught", "", "sigcatch"}, - {"command", "COMMAND", NULL, COMM|LJUST|USER, command, NULL, 16}, - {"cpu", "CPU", NULL, 0, pvar, NULL, 3, POFF(p_estcpu), UINT, "d"}, - {"cputime", "", "time"}, - {"f", "F", NULL, 0, pvar, NULL, 7, POFF(p_flag), INT, "x"}, - {"flags", "", "f"}, - {"ignored", "", "sigignore"}, - {"inblk", "INBLK", - NULL, USER, rvar, NULL, 4, ROFF(ru_inblock), LONG, "ld"}, - {"inblock", "", "inblk"}, - {"jobc", "JOBC", NULL, 0, evar, NULL, 4, EOFF(e_jobc), SHORT, "d"}, - {"ktrace", "KTRACE", - NULL, 0, pvar, NULL, 8, POFF(p_traceflag), INT, "x"}, - {"ktracep", "KTRACEP", - NULL, 0, pvar, NULL, 8, POFF(p_tracep), LONG, "lx"}, - {"lim", "LIM", NULL, 0, maxrss, NULL, 5}, - {"login", "LOGIN", NULL, LJUST, logname, NULL, MAXLOGNAME-1}, - {"logname", "", "login"}, - {"lstart", "STARTED", NULL, LJUST|USER, lstarted, NULL, 28}, - {"majflt", "MAJFLT", - NULL, USER, rvar, NULL, 4, ROFF(ru_majflt), LONG, "ld"}, - {"minflt", "MINFLT", - NULL, USER, rvar, NULL, 4, ROFF(ru_minflt), LONG, "ld"}, - {"msgrcv", "MSGRCV", - NULL, USER, rvar, NULL, 4, ROFF(ru_msgrcv), LONG, "ld"}, - {"msgsnd", "MSGSND", - NULL, USER, rvar, NULL, 4, ROFF(ru_msgsnd), LONG, "ld"}, - {"ni", "", "nice"}, - {"nice", "NI", NULL, 0, pvar, NULL, 2, POFF(p_nice), CHAR, "d"}, - {"nivcsw", "NIVCSW", - NULL, USER, rvar, NULL, 5, ROFF(ru_nivcsw), LONG, "ld"}, - {"nsignals", "", "nsigs"}, - {"nsigs", "NSIGS", - NULL, USER, rvar, NULL, 4, ROFF(ru_nsignals), LONG, "ld"}, - {"nswap", "NSWAP", - NULL, USER, rvar, NULL, 4, ROFF(ru_nswap), LONG, "ld"}, - {"nvcsw", "NVCSW", - NULL, USER, rvar, NULL, 5, ROFF(ru_nvcsw), LONG, "ld"}, - {"nwchan", "WCHAN", NULL, 0, pvar, NULL, 8, POFF(p_wchan), KPTR, "lx"}, - {"oublk", "OUBLK", - NULL, USER, rvar, NULL, 4, ROFF(ru_oublock), LONG, "ld"}, - {"oublock", "", "oublk"}, - {"p_ru", "P_RU", NULL, 0, pvar, NULL, 6, POFF(p_ru), KPTR, "lx"}, - {"paddr", "PADDR", NULL, 0, evar, NULL, 8, EOFF(e_paddr), KPTR, "lx"}, - {"pagein", "PAGEIN", NULL, USER, pagein, NULL, 6}, - {"pcpu", "", "%cpu"}, - {"pending", "", "sig"}, - {"pgid", "PGID", - NULL, 0, evar, NULL, PIDLEN, EOFF(e_pgid), UINT, PIDFMT}, - {"pid", "PID", NULL, 0, pvar, NULL, PIDLEN, POFF(p_pid), UINT, PIDFMT}, - {"pmem", "", "%mem"}, - {"ppid", "PPID", - NULL, 0, evar, NULL, PIDLEN, EOFF(e_ppid), UINT, PIDFMT}, - {"pri", "PRI", NULL, 0, pri, NULL, 3}, - {"re", "RE", NULL, 0, pvar, NULL, 3, POFF(p_swtime), UINT, "d"}, - {"rgid", "RGID", NULL, 0, evar, NULL, UIDLEN, EOFF(e_pcred.p_rgid), - UINT, UIDFMT}, - {"rlink", "RLINK", - NULL, 0, pvar, NULL, 8, POFF(p_procq.tqe_prev), KPTR, "lx"}, - {"rss", "RSS", NULL, 0, p_rssize, NULL, 4}, - {"rssize", "", "rsz"}, - {"rsz", "RSZ", NULL, 0, rssize, NULL, 4}, - {"rtprio", "RTPRIO", NULL, 0, rtprior, NULL, 7, POFF(p_rtprio)}, - {"ruid", "RUID", NULL, 0, evar, NULL, UIDLEN, EOFF(e_pcred.p_ruid), - UINT, UIDFMT}, - {"ruser", "RUSER", NULL, LJUST|DSIZ, runame, s_runame, USERLEN}, - {"sess", "SESS", NULL, 0, evar, NULL, 6, EOFF(e_sess), KPTR, "lx"}, - {"sig", "PENDING", NULL, 0, pvar, NULL, 8, POFF(p_siglist), INT, "x"}, - {"sigcatch", "CAUGHT", - NULL, 0, evar, NULL, 8, EOFF(e_procsig.ps_sigcatch), UINT, "x"}, - {"sigignore", "IGNORED", - NULL, 0, evar, NULL, 8, EOFF(e_procsig.ps_sigignore), UINT, "x"}, - {"sigmask", "BLOCKED", - NULL, 0, pvar, NULL, 8, POFF(p_sigmask), UINT, "x"}, - {"sl", "SL", NULL, 0, pvar, NULL, 3, POFF(p_slptime), UINT, "d"}, - {"start", "STARTED", NULL, LJUST|USER, started, NULL, 7}, - {"stat", "", "state"}, - {"state", "STAT", NULL, 0, state, NULL, 4}, - {"svgid", "SVGID", NULL, 0, - evar, NULL, UIDLEN, EOFF(e_pcred.p_svgid), UINT, UIDFMT}, - {"svuid", "SVUID", NULL, 0, - evar, NULL, UIDLEN, EOFF(e_pcred.p_svuid), UINT, UIDFMT}, - {"tdev", "TDEV", NULL, 0, tdev, NULL, 4}, - {"time", "TIME", NULL, USER, cputime, NULL, 9}, - {"tpgid", "TPGID", - NULL, 0, evar, NULL, 4, EOFF(e_tpgid), UINT, PIDFMT}, - {"tsess", "TSESS", NULL, 0, evar, NULL, 6, EOFF(e_tsess), KPTR, "lx"}, - {"tsiz", "TSIZ", NULL, 0, tsize, NULL, 4}, - {"tt", "TT ", NULL, 0, tname, NULL, 4}, - {"tty", "TTY", NULL, LJUST, longtname, NULL, 8}, - {"ucomm", "UCOMM", NULL, LJUST, ucomm, NULL, MAXCOMLEN}, - {"uid", "UID", NULL, 0, evar, NULL, UIDLEN, EOFF(e_ucred.cr_uid), - UINT, UIDFMT}, - {"upr", "UPR", NULL, 0, pvar, NULL, 3, POFF(p_usrpri), CHAR, "d"}, - {"user", "USER", NULL, LJUST|DSIZ, uname, s_uname, USERLEN}, - {"usrpri", "", "upr"}, - {"vsize", "", "vsz"}, - {"vsz", "VSZ", NULL, 0, vsize, NULL, 5}, - {"wchan", "WCHAN", NULL, LJUST, wchan, NULL, 6}, - {"xstat", "XSTAT", NULL, 0, pvar, NULL, 4, POFF(p_xstat), USHORT, "x"}, - {""}, + { "%cpu", "%CPU", NULL, 0, pcpu, NULL, 4 }, + { "%mem", "%MEM", NULL, 0, pmem, NULL, 4 }, + { "acflag", "ACFLG", NULL, + 0, pvar, NULL, 3, POFF(p_acflag), USHORT, "x" }, + { "acflg", NULL, "acflag" }, +#if defined(COMPAT_SUSV2) + { "addr", "ADDR", "paddr" }, + { "args", NULL, "command" }, +#endif + { "blocked", NULL, "sigmask" }, +#if defined(COMPAT_SUSV2) + { "c", "C", NULL, 0, pvar, NULL, 1, POFF(p_oncpu), UCHAR, "d" }, +#endif + { "caught", NULL, "sigcatch" }, +#if defined(COMPAT_SUSV2) + { "comm", "COMMAND", "ucomm" }, +#endif + { "command", "COMMAND", NULL, COMM|LJUST|USER, command, NULL, 16 }, + { "cpu", "CPU", NULL, 0, pvar, NULL, 3, POFF(p_estcpu), UINT, "d" }, + { "cputime", NULL, "time" }, +#if defined(COMPAT_SUSV2) + { "etime", "ELAPSED", NULL, USER, etime, NULL, 11 }, +#endif + { "f", "F", NULL, 0, pvar, NULL, 7, POFF(p_flag), INT, "x" }, + { "flags", NULL, "f" }, +#if defined(COMPAT_SUSV2) + { "group", "GROUP", NULL, LJUST|DSIZ, gname, s_gname, USERLEN }, +#endif + { "ignored", NULL, "sigignore" }, + { "inblk", "INBLK", NULL, + USER, rvar, NULL, 4, ROFF(ru_inblock), LONG, "ld" }, + { "inblock", NULL, "inblk" }, + { "jobc", "JOBC", NULL, 0, evar, NULL, 4, EOFF(e_jobc), SHORT, "d" }, + { "ktrace", "KTRACE", NULL, + 0, pvar, NULL, 8, POFF(p_traceflag), INT, "x" }, + { "ktracep", "KTRACEP", NULL, + 0, pvar, NULL, 8, POFF(p_tracep), LONG, "lx" }, +#if defined(COMPAT_SUSV2) + { "l", "L", "state" }, +#endif + { "lim", "LIM", NULL, 0, maxrss, NULL, 5 }, + { "login", "LOGIN", NULL, LJUST, logname, NULL, MAXLOGNAME-1 }, + { "logname", NULL, "login" }, + { "lstart", "STARTED", NULL, LJUST|USER, lstarted, NULL, 28 }, + { "majflt", "MAJFLT", NULL, + USER, rvar, NULL, 7, ROFF(ru_majflt), LONG, "ld" }, + { "minflt", "MINFLT", NULL, + USER, rvar, NULL, 7, ROFF(ru_minflt), LONG, "ld" }, + { "msgrcv", "MSGRCV", NULL, + USER, rvar, NULL, 7, ROFF(ru_msgrcv), LONG, "ld" }, + { "msgsnd", "MSGSND", NULL, + USER, rvar, NULL, 7, ROFF(ru_msgsnd), LONG, "ld" }, + { "ni", NULL, "nice" }, +/* SUSV2 */ + { "nice", "NI", NULL, 0, pvar, NULL, 3, POFF(p_nice), CHAR, "d" }, + { "nivcsw", "NIVCSW", NULL, + USER, rvar, NULL, 5, ROFF(ru_nivcsw), LONG, "ld" }, + { "nsignals", NULL, "nsigs" }, + { "nsigs", "NSIGS", NULL, + USER, rvar, NULL, 4, ROFF(ru_nsignals), LONG, "ld" }, + { "nswap", "NSWAP", NULL, + USER, rvar, NULL, 4, ROFF(ru_nswap), LONG, "ld" }, + { "nvcsw", "NVCSW", NULL, + USER, rvar, NULL, 5, ROFF(ru_nvcsw), LONG, "ld" }, + { "nwchan", "WCHAN", NULL, + 0, pvar, NULL, 8, POFF(p_wchan), KPTR, "lx" }, + { "oublk", "OUBLK", NULL, + USER, rvar, NULL, 6, ROFF(ru_oublock), LONG, "ld" }, + { "oublock", NULL, "oublk" }, + { "p_ru", "P_RU", NULL, 0, pvar, NULL, 6, POFF(p_ru), KPTR, "lx" }, + { "paddr", "PADDR", NULL, + 0, evar, NULL, 8, EOFF(e_paddr), KPTR, "lx" }, + { "pagein", "PAGEIN", NULL, USER, pagein, NULL, 6 }, +/* SUSV2 */ + { "pcpu", NULL, "%cpu" }, + { "pending", NULL, "sig" }, +/* SUSV2 */ + { "pgid", "PGID", NULL, + 0, evar, NULL, PIDLEN, EOFF(e_pgid), UINT, PIDFMT }, +/* SUSV2 */ + { "pid", "PID", NULL, + 0, pvar, NULL, PIDLEN, POFF(p_pid), UINT, PIDFMT }, + { "pmem", NULL, "%mem" }, +/* SUSV2 */ + { "ppid", "PPID", NULL, + 0, evar, NULL, PIDLEN, EOFF(e_ppid), UINT, PIDFMT }, + { "pri", "PRI", NULL, 0, pri, NULL, 3 }, + { "re", "RE", NULL, 0, pvar, NULL, 6, POFF(p_swtime), UINT, "d" }, + { "rgid", "RGID", NULL, + 0, evar, NULL, UIDLEN, EOFF(e_pcred.p_rgid), UINT, UIDFMT }, +#if defined(COMPAT_SUSV2) + { "rgroup", "RGROUP", NULL, LJUST|DSIZ, rgname, s_rgname, USERLEN }, +#endif + { "rlink", "RLINK", NULL, + 0, pvar, NULL, 8, POFF(p_procq.tqe_prev), KPTR, "lx" }, + { "rss", "RSS", NULL, 0, p_rssize, NULL, 5 }, + { "rssize", NULL, "rsz" }, + { "rsz", "RSZ", NULL, 0, rssize, NULL, 5 }, + { "rtprio", "RTPRIO", NULL, 0, rtprior, NULL, 7, POFF(p_rtprio) }, + { "ruid", "RUID", NULL, + 0, evar, NULL, UIDLEN, EOFF(e_pcred.p_ruid), UINT, UIDFMT }, +/* SUSV2 */ + { "ruser", "RUSER", NULL, LJUST|DSIZ, runame, s_runame, USERLEN }, + { "s", "S", "state" }, + { "sess", "SESS", NULL, 0, evar, NULL, 7, EOFF(e_sess), KPTR, "lx" }, +/* SVR4 { "sid", "SID", "sess" }, */ + { "sig", "PENDING", NULL, + 0, pvar, NULL, 8, POFF(p_siglist), INT, "x" }, + { "sigcatch", "CAUGHT", NULL, + 0, evar, NULL, 8, EOFF(e_procsig.ps_sigcatch), UINT, "x" }, + { "sigignore", "IGNORED", NULL, + 0, evar, NULL, 8, EOFF(e_procsig.ps_sigignore), UINT, "x" }, + { "sigmask", "BLOCKED", NULL, + 0, pvar, NULL, 8, POFF(p_sigmask), UINT, "x" }, + { "sl", "SL", NULL, 0, pvar, NULL, 6, POFF(p_slptime), UINT, "d" }, + { "start", "STARTED", NULL, LJUST|USER, started, NULL, 7 }, + { "stat", NULL, "state" }, + { "state", "STAT", NULL, 0, state, NULL, 4 }, +#if defined(COMPAT_SUSV2) + { "stime", "STIME", NULL, USER, stime, NULL, 8 }, +#endif + { "svgid", "SVGID", NULL, + 0, evar, NULL, UIDLEN, EOFF(e_pcred.p_svgid), UINT, UIDFMT }, + { "svuid", "SVUID", NULL, + 0, evar, NULL, UIDLEN, EOFF(e_pcred.p_svuid), UINT, UIDFMT }, + { "tdev", "TDEV", NULL, 0, tdev, NULL, 4 }, +/* SUSV2 */ + { "time", "TIME", NULL, USER, cputime, NULL, 9 }, + { "tpgid", "TPGID", NULL, + 0, evar, NULL, 6, EOFF(e_tpgid), UINT, PIDFMT }, + { "tsess", "TSESS", NULL, + 0, evar, NULL, 7, EOFF(e_tsess), KPTR, "lx" }, + { "tsiz", "TSIZ", NULL, 0, tsize, NULL, 5 }, + { "tt", "TT ", NULL, 0, tname, NULL, 4 }, +/* SUSV2 */ + { "tty", "TTY", NULL, LJUST, longtname, NULL, 8 }, + { "ucomm", "UCOMM", NULL, LJUST, ucomm, NULL, MAXCOMLEN }, + { "uid", "UID", NULL, + 0, evar, NULL, UIDLEN, EOFF(e_ucred.cr_uid), UINT, UIDFMT }, + { "upr", "UPR", NULL, 0, pvar, NULL, 3, POFF(p_usrpri), CHAR, "d" }, +/* SUSV2 */ + { "user", "USER", NULL, LJUST|DSIZ, uname, s_uname, USERLEN }, + { "usrpri", NULL, "upr" }, + { "vsize", NULL, "vsz" }, +/* SUSV2 */ + { "vsz", "VSZ", NULL, 0, vsize, NULL, 5 }, + { "wchan", "WCHAN", NULL, LJUST, wchan, NULL, 7 }, + { "xstat", "XSTAT", NULL, + 0, pvar, NULL, 4, POFF(p_xstat), USHORT, "x" }, + { "" }, }; void @@ -213,65 +265,128 @@ (void) printf("\n"); } +#if defined(COMPAT_BSD44) void -parsefmt(p) +bsd_parsefmt(p) char *p; { - static struct varent *vtail; + bsd_parsefmt1(p, NULL); +} -#define FMTSEP " \t,\n" - while (p && *p) { - char *cp; - VAR *v; - struct varent *vent; +static void +bsd_parsefmt1(p, h) + char *p, *h; +{ + char *cp, *hp; + VAR *v; + VARENT *vent; + while (p && *p) { while ((cp = strsep(&p, FMTSEP)) != NULL && *cp == '\0') /* void */; - if (cp == NULL || !(v = findvar(cp))) + if ((hp = strchr(cp, '=')) != NULL) + *hp++ = '\0'; + if (cp == NULL || !(v = findvar(cp, hp ? hp : h))) continue; - if ((vent = malloc(sizeof(struct varent))) == NULL) + if ((vent = malloc(sizeof(VARENT))) == NULL) err(1, NULL); vent->var = v; - vent->next = NULL; - if (vhead == NULL) - vhead = vtail = vent; - else { - vtail->next = vent; - vtail = vent; + STAILQ_INSERT_TAIL(&varlist, vent, list); + } + if (STAILQ_EMPTY(&varlist)) + errx(1, "no valid keywords"); +} +#endif + +#if defined(COMPAT_SUSV2) +void +susv2_parsefmt(p, f) + char *p, *f; +{ + susv2_parsefmt1(p, f, NULL); +} + +static void +susv2_parsefmt1(p, f, h) + char *p, *f, *h; +{ + char *cp, *hp; + VAR *v; + VARENT *vent; +loop: + while (p && *p) { + while ((cp = strsep(&p, FMTSEP)) != NULL && *cp == '\0') + /* void */; + if (cp == NULL) + continue; + if ((hp = strpbrk(cp, "[=")) != NULL) { + switch (*hp) { + case '[': + if (!f || !*f || strpbrk(hp, f)) + *hp++ = '\0'; + else + continue; + if (!(hp = strchr(hp, '='))) + break; + /* FALLTHROUGH */ + case '=': + *hp++ = '\0'; + } } + if (!(v = findvar(cp, hp ? hp : h))) + continue; + STAILQ_FOREACH(vent, &varlist, list) + if (!strcmp(v->name, vent->var->name)) { + free(v); + goto loop; + } + if ((vent = malloc(sizeof(VARENT))) == NULL) + err(1, NULL); + vent->var = v; + STAILQ_INSERT_TAIL(&varlist, vent, list); } - if (!vhead) + if (STAILQ_EMPTY(&varlist)) errx(1, "no valid keywords"); } +#endif static VAR * -findvar(p) - char *p; +findvar(p, h) + char *p, *h; { VAR *v, key; - char *hp; - int vcmp(); - - hp = strchr(p, '='); - if (hp) - *hp++ = '\0'; key.name = p; v = bsearch(&key, var, sizeof(var)/sizeof(VAR) - 1, sizeof(VAR), vcmp); if (v && v->alias) { - if (hp) { +#if defined(COMPAT_BSD44) + if (h) { + h = NULL; warnx("%s: illegal keyword specification", p); eval = 1; } - parsefmt(v->alias); +#endif +#if defined(COMPAT_SUSV2) + susv2_parsefmt1(v->alias, NULL, h ? h : v->header); +#else + bsd_parsefmt1(v->alias, h ? h : v->header); +#endif return ((VAR *)NULL); } if (!v) { warnx("%s: keyword not found", p); eval = 1; - } else if (hp) - v->header = hp; + } else if (h) { + VAR *vp; + + if ((vp = malloc(sizeof(VAR))) == NULL) + err(1, NULL); + memcpy(vp, v, sizeof(VAR)); + v = vp; + if ((v->header = strdup(h)) == NULL) + err(1, NULL); + } return (v); } Index: nlist.c =================================================================== RCS file: /home/ncvs/src/bin/ps/nlist.c,v retrieving revision 1.12.6.2 diff -u -r1.12.6.2 nlist.c --- nlist.c 1 Aug 2001 05:04:48 -0000 1.12.6.2 +++ nlist.c 25 May 2002 17:12:30 -0000 @@ -32,11 +32,11 @@ */ #ifndef lint +#include #if 0 -static char sccsid[] = "@(#)nlist.c 8.4 (Berkeley) 4/2/94"; +__RCSID("@(#)nlist.c 8.4 (Berkeley) 4/2/94"); #endif -static const char rcsid[] = - "$FreeBSD: src/bin/ps/nlist.c,v 1.12.6.2 2001/08/01 05:04:48 obrien Exp $"; +__FBSDID("$FreeBSD: src/bin/ps/nlist.c,v 1.12.6.2 2001/08/01 05:04:48 obrien Exp $"); #endif /* not lint */ #include Index: print.c =================================================================== RCS file: /home/ncvs/src/bin/ps/print.c,v retrieving revision 1.36.2.3 diff -u -r1.36.2.3 print.c --- print.c 12 Mar 2002 18:12:57 -0000 1.36.2.3 +++ print.c 25 May 2002 17:18:09 -0000 @@ -32,11 +32,11 @@ */ #ifndef lint +#include #if 0 -static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; +__RCSID("@(#)print.c 8.6 (Berkeley) 4/16/94"); #endif -static const char rcsid[] = - "$FreeBSD: src/bin/ps/print.c,v 1.36.2.3 2002/03/12 18:12:57 phantom Exp $"; +__FBSDID("$FreeBSD: src/bin/ps/print.c,v 1.36.2.3 2002/03/12 18:12:57 phantom Exp $"); #endif /* not lint */ #include @@ -44,10 +44,10 @@ #include #include #include - #include #include #include +#include #include #include @@ -64,22 +64,44 @@ #include "ps.h" +#define FMTLEN 64 +#define BUFLEN 128 + +static const char sfmt[] = "%s"; +static const char wsfmt[] = "%*s"; +static const char wwsfmt[] = "%*.*s"; +static const char lwsfmt[] = "%-*s"; +static const char lwwsfmt[] = "%-*.*s"; +static const char wdfmt[] = "%*d"; +static const char wldfmt[] = "%*ld"; +static const char wlufmt[] = "%*lu"; +static const char wffmt[] = "%*.1f"; + +static void gettime __P((time_t *, struct timeval *)); +static double getpmem __P((KINFO *)); +static void printval __P((char *, VAR *v)); + void printheader() { VAR *v; - struct varent *vent; + VARENT *vent; - for (vent = vhead; vent; vent = vent->next) { + STAILQ_FOREACH(vent, &varlist, list) + if (*vent->var->header) + break; + if (!vent) + return; + STAILQ_FOREACH(vent, &varlist, list) { v = vent->var; if (v->flag & LJUST) { - if (vent->next == NULL) /* last one */ - (void)printf("%s", v->header); + if (STAILQ_NEXT(vent, list) == NULL) /* last one */ + (void)printf(sfmt, v->header); else - (void)printf("%-*s", v->width, v->header); + (void)printf(lwsfmt, v->width, v->header); } else - (void)printf("%*s", v->width, v->header); - if (vent->next != NULL) + (void)printf(wsfmt, v->width, v->header); + if (STAILQ_NEXT(vent, list) != NULL) (void)putchar(' '); } (void)putchar('\n'); @@ -97,10 +119,10 @@ v = ve->var; if (cflag) { - if (ve->next == NULL) /* last field, don't pad */ - (void)printf("%s", KI_PROC(k)->p_comm); + if (STAILQ_NEXT(ve, list) == NULL) /* last field, don't pad */ + (void)printf(sfmt, KI_PROC(k)->p_comm); else - (void)printf("%-*s", v->width, KI_PROC(k)->p_comm); + (void)printf(lwsfmt, v->width, KI_PROC(k)->p_comm); return; } @@ -114,12 +136,13 @@ } else vis_env = NULL; - if (ve->next == NULL) { - /* last field */ + if (STAILQ_NEXT(ve, list) == NULL) { /* last field */ if (termwidth == UNLIMITED) { - if (vis_env) - (void)printf("%s ", vis_env); - (void)printf("%s", vis_args); + if (vis_env) { + (void)printf(sfmt, vis_env); + (void)putchar(' '); + } + (void)printf(sfmt, vis_args); } else { left = termwidth - (totwidth - v->width); if (left < 1) /* already wrapped, just use std width */ @@ -128,14 +151,14 @@ while (--left >= 0 && *cp) (void)putchar(*cp++); if (--left >= 0) - putchar(' '); + (void)putchar(' '); } for (cp = vis_args; --left >= 0 && *cp != '\0';) (void)putchar(*cp++); } } else /* XXX env? */ - (void)printf("%-*.*s", v->width, v->width, vis_args); + (void)printf(lwwsfmt, v->width, v->width, vis_args); free(vis_args); if (vis_env != NULL) free(vis_env); @@ -149,7 +172,7 @@ VAR *v; v = ve->var; - (void)printf("%-*s", v->width, KI_PROC(k)->p_comm); + (void)printf(lwsfmt, v->width, KI_PROC(k)->p_comm); } void @@ -161,7 +184,8 @@ char *s; v = ve->var; - (void)printf("%-*s", v->width, (s = KI_EPROC(k)->e_login, *s) ? s : "-"); + (void)printf(lwsfmt, v->width, + (s = KI_EPROC(k)->e_login, *s) ? s : "-"); } void @@ -173,7 +197,7 @@ int flag; char *cp; VAR *v; - char buf[16]; + char buf[BUFLEN]; v = ve->var; p = KI_PROC(k); @@ -183,29 +207,28 @@ switch (p->p_stat) { case SSTOP: - *cp = 'T'; + *cp++ = 'T'; break; case SSLEEP: if (flag & P_SINTR) /* interruptable (long) */ - *cp = p->p_slptime >= MAXSLP ? 'I' : 'S'; + *cp++ = p->p_slptime >= MAXSLP ? 'I' : 'S'; else - *cp = 'D'; + *cp++ = 'D'; break; case SRUN: case SIDL: - *cp = 'R'; + *cp++ = 'R'; break; case SZOMB: - *cp = 'Z'; + *cp++ = 'Z'; break; default: - *cp = '?'; + *cp++ = '?'; } - cp++; if (!(flag & P_INMEM)) *cp++ = 'W'; if (p->p_nice < NZERO) @@ -222,12 +245,13 @@ *cp++ = 'L'; if (KI_EPROC(k)->e_flag & EPROC_SLEADER) *cp++ = 's'; - if ((flag & P_CONTROLT) && KI_EPROC(k)->e_pgid == KI_EPROC(k)->e_tpgid) + if ((flag & P_CONTROLT) && + KI_EPROC(k)->e_pgid == KI_EPROC(k)->e_tpgid) *cp++ = '+'; if (flag & P_JAILED) *cp++ = 'J'; *cp = '\0'; - (void)printf("%-*s", v->width, buf); + (void)printf(lwsfmt, v->width, buf); } void @@ -238,7 +262,12 @@ VAR *v; v = ve->var; - (void)printf("%*d", v->width, KI_PROC(k)->p_priority - PZERO); +#if defined(COMPAT_SUSV2) + if (susv2) + (void)printf(wdfmt, v->width, KI_PROC(k)->p_priority); + else +#endif + (void)printf(wdfmt, v->width, KI_PROC(k)->p_priority - PZERO); } void @@ -249,8 +278,8 @@ VAR *v; v = ve->var; - (void)printf("%-*s", - (int)v->width, user_from_uid(KI_EPROC(k)->e_ucred.cr_uid, 0)); + (void)printf(lwsfmt, v->width, + user_from_uid(KI_EPROC(k)->e_ucred.cr_uid, 0)); } int @@ -268,17 +297,57 @@ VAR *v; v = ve->var; - (void)printf("%-*s", - (int)v->width, user_from_uid(KI_EPROC(k)->e_pcred.p_ruid, 0)); + (void)printf(lwsfmt, v->width, + user_from_uid(KI_EPROC(k)->e_pcred.p_ruid, 0)); } int s_runame(k) KINFO *k; { - return (strlen(user_from_uid(KI_EPROC(k)->e_pcred.p_ruid, 0))); + return (strlen(user_from_uid(KI_EPROC(k)->e_pcred.p_ruid, 0))); } +#if defined(COMPAT_SUSV2) +void +gname(k, ve) + KINFO *k; + VARENT *ve; +{ + VAR *v; + + v = ve->var; + (void)printf(lwsfmt, v->width, + group_from_gid(KI_EPROC(k)->e_ucred.cr_gid, 0)); +} + +int +s_gname(k) + KINFO *k; +{ + return (strlen(group_from_gid(KI_EPROC(k)->e_ucred.cr_gid, 0))); +} + +void +rgname(k, ve) + KINFO *k; + VARENT *ve; +{ + VAR *v; + + v = ve->var; + (void)printf(lwsfmt, v->width, + group_from_gid(KI_EPROC(k)->e_pcred.p_rgid, 0)); +} + +int +s_rgname(k) + KINFO *k; +{ + return (strlen(group_from_gid(KI_EPROC(k)->e_pcred.p_rgid, 0))); +} +#endif + void tdev(k, ve) KINFO *k; @@ -286,16 +355,16 @@ { VAR *v; dev_t dev; - char buff[16]; + char buf[BUFLEN]; v = ve->var; dev = KI_EPROC(k)->e_tdev; if (dev == NODEV) - (void)printf("%*s", v->width, "??"); + (void)printf(wsfmt, v->width, "??"); else { - (void)snprintf(buff, sizeof(buff), + (void)snprintf(buf, sizeof(buf), "%d/%d", major(dev), minor(dev)); - (void)printf("%*s", v->width, buff); + (void)printf(wsfmt, v->width, buf); } } @@ -311,13 +380,13 @@ v = ve->var; dev = KI_EPROC(k)->e_tdev; if (dev == NODEV || (ttname = devname(dev, S_IFCHR)) == NULL) - (void)printf("%*s ", v->width-1, "??"); + (void)printf(wsfmt, v->width, "?? "); else { if (strncmp(ttname, "tty", 3) == 0 || strncmp(ttname, "cua", 3) == 0) ttname += 3; - (void)printf("%*.*s%c", v->width-1, v->width-1, ttname, - KI_EPROC(k)->e_flag & EPROC_CTTY ? ' ' : '-'); + (void)printf(wwsfmt, v->width-1, v->width-1, ttname); + (void)putchar(KI_EPROC(k)->e_flag & EPROC_CTTY ? ' ' : '-'); } } @@ -333,9 +402,27 @@ v = ve->var; dev = KI_EPROC(k)->e_tdev; if (dev == NODEV || (ttname = devname(dev, S_IFCHR)) == NULL) - (void)printf("%-*s", v->width, "??"); + (void)printf(lwsfmt, v->width, "??"); else - (void)printf("%-*s", v->width, ttname); + (void)printf(lwsfmt, v->width, ttname); +} + +static void +gettime(tp, tvp) + time_t *tp; + struct timeval *tvp; +{ + static time_t t; + static struct timeval tv; + + if (!t) { + (void)time(&t); + (void)gettimeofday(&tv, NULL); + } + if (tp) + *tp = t; + if (tvp) + *tvp = tv; } void @@ -344,15 +431,15 @@ VARENT *ve; { VAR *v; - static time_t now; + time_t now; time_t then; struct tm *tp; - char buf[100]; + char buf[BUFLEN]; static int use_ampm = -1; v = ve->var; if (!k->ki_u.u_valid) { - (void)printf("%-*s", v->width, "-"); + (void)printf(lwsfmt, v->width, "-"); return; } @@ -361,18 +448,48 @@ then = k->ki_u.u_start.tv_sec; tp = localtime(&then); - if (!now) - (void)time(&now); + gettime(&now, NULL); if (now - k->ki_u.u_start.tv_sec < 24 * 3600) { (void)strftime(buf, sizeof(buf) - 1, use_ampm ? "%l:%M%p" : "%k:%M ", tp); } else if (now - k->ki_u.u_start.tv_sec < 7 * 86400) { (void)strftime(buf, sizeof(buf) - 1, use_ampm ? "%a%I%p" : "%a%H ", tp); - } else - (void)strftime(buf, sizeof(buf) - 1, "%e%b%y", tp); - (void)printf("%-*s", v->width, buf); + } else { + static const char fmt[] = "%e%b%y"; /* avoid gcc warning */ + (void)strftime(buf, sizeof(buf) - 1, fmt, tp); + } + (void)printf(lwsfmt, v->width, buf); +} + +#if defined(COMPAT_SUSV2) +void +stime(k, ve) + KINFO *k; + VARENT *ve; +{ + VAR *v; + time_t now; + time_t then; + struct tm *tp; + char buf[BUFLEN]; + + v = ve->var; + if (!k->ki_u.u_valid) { + (void)printf(lwsfmt, v->width, "-"); + return; + } + + then = k->ki_u.u_start.tv_sec; + tp = localtime(&then); + gettime(&now, NULL); + if (now - k->ki_u.u_start.tv_sec < 24 * 3600) + (void)strftime(buf, sizeof(buf) - 1, "%T", tp); + else + (void)strftime(buf, sizeof(buf) - 1, "%b %d", tp); + (void)printf(wsfmt, v->width, buf); } +#endif void lstarted(k, ve) @@ -381,16 +498,17 @@ { VAR *v; time_t then; - char buf[100]; + char buf[BUFLEN]; + static const char fmt[] = "%c"; /* avoid gcc warning */ v = ve->var; if (!k->ki_u.u_valid) { - (void)printf("%-*s", v->width, "-"); + (void)printf(lwsfmt, v->width, "-"); return; } then = k->ki_u.u_start.tv_sec; - (void)strftime(buf, sizeof(buf) -1, "%c", localtime(&then)); - (void)printf("%-*s", v->width, buf); + (void)strftime(buf, sizeof(buf) -1, fmt, localtime(&then)); + (void)printf(lwsfmt, v->width, buf); } void @@ -403,13 +521,13 @@ v = ve->var; if (KI_PROC(k)->p_wchan) { if (KI_PROC(k)->p_wmesg) - (void)printf("%-*.*s", v->width, v->width, + (void)printf(lwwsfmt, v->width, v->width, KI_EPROC(k)->e_wmesg); else (void)printf("%-*lx", v->width, (long)KI_PROC(k)->p_wchan); } else - (void)printf("%-*s", v->width, "-"); + (void)printf(lwsfmt, v->width, "-"); } #ifndef pgtok @@ -424,7 +542,7 @@ VAR *v; v = ve->var; - (void)printf("%*d", v->width, + (void)printf(wdfmt, v->width, (KI_EPROC(k)->e_vm.vm_map.size/1024)); } @@ -437,7 +555,7 @@ v = ve->var; /* XXX don't have info about shared */ - (void)printf("%*lu", v->width, + (void)printf(wlufmt, v->width, (u_long)pgtok(KI_EPROC(k)->e_vm.vm_rssize)); } @@ -449,7 +567,8 @@ VAR *v; v = ve->var; - (void)printf("%*ld", v->width, (long)pgtok(KI_EPROC(k)->e_vm.vm_rssize)); + (void)printf(wldfmt, v->width, + (long)pgtok(KI_EPROC(k)->e_vm.vm_rssize)); } void @@ -460,11 +579,14 @@ VAR *v; long secs; long psecs; /* "parts" of a second. first micro, then centi */ - char obuff[128]; + long mins, hours, days; + char fmt[FMTLEN]; + char buf[BUFLEN]; static char decimal_point = 0; if (!decimal_point) decimal_point = localeconv()->decimal_point[0]; + v = ve->var; if (KI_PROC(k)->p_stat == SZOMB || !k->ki_u.u_valid) { secs = 0; @@ -481,7 +603,7 @@ secs += k->ki_u.u_cru.ru_utime.tv_sec + k->ki_u.u_cru.ru_stime.tv_sec; psecs += k->ki_u.u_cru.ru_utime.tv_usec + - k->ki_u.u_cru.ru_stime.tv_usec; + k->ki_u.u_cru.ru_stime.tv_usec; } /* * round and scale to 100's @@ -490,10 +612,75 @@ secs += psecs / 100; psecs = psecs % 100; } - (void)snprintf(obuff, sizeof(obuff), - "%3ld:%02ld%c%02ld", secs/60, secs%60, decimal_point, psecs); - (void)printf("%*s", v->width, obuff); + mins = secs / 60; + *fmt = '\0'; +#if defined(COMPAT_SUSV2) + if (susv2) { + hours = mins / 60; + days = hours / 24; + hours %= 24; + mins %= 60; + if (days) + strcat(fmt, "%6$02ld-"); + strcat(fmt, "%5$02ld:%1$02ld:%2$02ld"); + } else +#endif + { + hours = days = 0; + strcat(fmt, "%3ld:%02ld%c%02ld"); + } + secs %= 60; + (void)snprintf(buf, sizeof(buf), fmt, + mins, secs, decimal_point, psecs, hours, days); + (void)printf(wsfmt, v->width, buf); +} + +#if defined(COMPAT_SUSV2) +void +etime +(k, ve) + KINFO *k; + VARENT *ve; +{ + VAR *v; + struct timeval now; + long psecs, secs, mins, hours, days; + char fmt[FMTLEN]; + char buf[BUFLEN]; + + v = ve->var; + if (!k->ki_u.u_valid) { + (void)printf(wsfmt, v->width, "-"); + return; + } + gettime(NULL, &now); + secs = now.tv_sec - k->ki_u.u_start.tv_sec; + psecs = now.tv_usec - k->ki_u.u_start.tv_usec; + if (psecs < 0) + secs--, psecs += 1000000; + mins = secs / 60; + *fmt = '\0'; +#if defined(COMPAT_SUSV2) + if (susv2) { + hours = mins / 60; + days = hours / 24; + hours %= 24; + mins %= 60; + if (days) + strcat(fmt, "%5$02ld-"); + if (hours) + strcat(fmt, "%4$02ld:"); + strcat(fmt, "%1$02ld:%2$02ld"); + } else +#endif + strcat(fmt, "%3ld:%02ld.%02ld"); + secs %= 60; + (void)snprintf(buf, sizeof(buf), fmt, mins, secs, psecs, hours, days); + (void)printf(wsfmt, v->width, buf); } +#endif + +#define fxtofl(fixpt) ((double)(fixpt) / fscale) double getpcpu(k) @@ -508,7 +695,6 @@ return (0.0); p = KI_PROC(k); -#define fxtofl(fixpt) ((double)(fixpt) / fscale) /* XXX - I don't like this */ if (p->p_swtime == 0 || (p->p_flag & P_INMEM) == 0) @@ -527,10 +713,10 @@ VAR *v; v = ve->var; - (void)printf("%*.1f", v->width, getpcpu(k)); + (void)printf(wffmt, v->width, getpcpu(k)); } -double +static double getpmem(k) KINFO *k; { @@ -564,7 +750,7 @@ VAR *v; v = ve->var; - (void)printf("%*.1f", v->width, getpmem(k)); + (void)printf(wffmt, v->width, getpmem(k)); } void @@ -575,7 +761,7 @@ VAR *v; v = ve->var; - (void)printf("%*ld", v->width, + (void)printf(wldfmt, v->width, k->ki_u.u_valid ? k->ki_u.u_ru.ru_majflt : 0); } @@ -588,7 +774,7 @@ v = ve->var; /* XXX not yet */ - (void)printf("%*s", v->width, "-"); + (void)printf(wsfmt, v->width, "-"); } void @@ -599,7 +785,8 @@ VAR *v; v = ve->var; - (void)printf("%*ld", v->width, (long)pgtok(KI_EPROC(k)->e_vm.vm_tsize)); + (void)printf(wldfmt, v->width, + (long)pgtok(KI_EPROC(k)->e_vm.vm_tsize)); } void @@ -609,7 +796,7 @@ { VAR *v; struct rtprio *prtp; - char str[8]; + char buf[BUFLEN]; unsigned prio, type; v = ve->var; @@ -618,20 +805,20 @@ type = prtp->type; switch (type) { case RTP_PRIO_REALTIME: - snprintf(str, sizeof(str), "real:%u", prio); + snprintf(buf, sizeof(buf), "real:%u", prio); break; case RTP_PRIO_NORMAL: - strncpy(str, "normal", sizeof(str)); + strncpy(buf, "normal", sizeof(buf)); break; case RTP_PRIO_IDLE: - snprintf(str, sizeof(str), "idle:%u", prio); + snprintf(buf, sizeof(buf), "idle:%u", prio); break; default: - snprintf(str, sizeof(str), "%u:%u", type, prio); + snprintf(buf, sizeof(buf), "%u:%u", type, prio); break; } - str[sizeof(str) - 1] = '\0'; - (void)printf("%*s", v->width, str); + buf[sizeof(buf) - 1] = '\0'; + (void)printf(wsfmt, v->width, buf); } /* @@ -643,7 +830,7 @@ char *bp; VAR *v; { - static char ofmt[32] = "%"; + static char ofmt[FMTLEN] = "%"; char *fcp, *cp; cp = ofmt + 1; @@ -719,7 +906,7 @@ if (k->ki_u.u_valid) printval((char *)((char *)&k->ki_u + v->off), v); else - (void)printf("%*s", v->width, "-"); + (void)printf(wsfmt, v->width, "-"); } void @@ -733,5 +920,5 @@ if (k->ki_u.u_valid) printval((char *)((char *)(&k->ki_u.u_ru) + v->off), v); else - (void)printf("%*s", v->width, "-"); + (void)printf(wsfmt, v->width, "-"); } Index: ps.c =================================================================== RCS file: /home/ncvs/src/bin/ps/ps.c,v retrieving revision 1.30.2.5 diff -u -r1.30.2.5 ps.c --- ps.c 1 Feb 2002 14:09:30 -0000 1.30.2.5 +++ ps.c 11 Jun 2002 02:30:49 -0000 @@ -32,17 +32,13 @@ */ #ifndef lint -static char const copyright[] = -"@(#) Copyright (c) 1990, 1993, 1994\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint +#include +__COPYRIGHT("@(#) Copyright (c) 1990, 1993, 1994\\n\ + The Regents of the University of California. All rights reserved.\\n"); #if 0 -static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; +__RCSID("@(#)ps.c 8.4 (Berkeley) 4/2/94"); #endif -static const char rcsid[] = - "$FreeBSD: src/bin/ps/ps.c,v 1.30.2.5 2002/02/01 14:09:30 ru Exp $"; +__FBSDID("$FreeBSD: src/bin/ps/ps.c,v 1.30.2.5 2002/02/01 14:09:30 ru Exp $"); #endif /* not lint */ #include @@ -52,6 +48,7 @@ #include #include #include +#include #include #include @@ -66,67 +63,125 @@ #include #include #include +#if defined(COMPAT_SUSV2) +#include +#endif #include #include #include "ps.h" -#define SEP ", \t" /* username separators */ +#define SEP ", \t" /* username separators */ +#define BUCKETS 32 /* power of 2 */ +#define SUSV2ENV "SUSV2" /* getenv() */ +#define OPTLEN 64 +#define UIDLEN 32 + +enum entry { + DEV, UID, PID +#if defined(COMPAT_SUSV2) + , FMT, GID, PGID, CMD +#endif +}; + +enum sort { + DEFAULT, SORTMEM, SORTCPU +}; + +/* + * Global variables + */ KINFO *kinfo; -struct varent *vhead, *vtail; +VARLIST varlist = STAILQ_HEAD_INITIALIZER(varlist); -int eval; /* exit value */ -int cflag; /* -c */ -int rawcpu; /* -C */ -int sumrusage; /* -S */ -int termwidth; /* width of screen (0 == infinity) */ +int eval; /* exit value */ +int rawcpu; /* -C */ +int cflag; /* -c */ +int sumrusage; /* -S */ +int termwidth; /* -w : width of screen (0 == infinity) */ int totwidth; /* calculated width of requested variables */ -static int needuser, needcomm, needenv; +#if defined(COMPAT_SUSV2) +int susv2; /* atoi(getenv("SUSV2")) != 0 */ +#endif + +/* + * Local variables + */ + + /* bsd options | susv2 options */ +static int all; /* -a | -a, -d, or -e */ +#if defined(COMPAT_SUSV2) +static char **cmds; /* nop | -C */ +static int ncmds; /* ditto */ +#endif +static int needenv; /* -e */ #if defined(LAZY_PS) -static int forceuread=0; +static int forceuread; /* -f | nop */ #else -static int forceuread=1; +static int forceuread = 1; /* ditto */ #endif +#if defined(COMPAT_SUSV2) +static pid_t *pgids; /* nop | -g */ +static int npgids; /* ditto */ +#endif +static int prtheader; /* -h */ +static char *memf = _PATH_DEVNULL; /* -M | -m */ +static enum sort sortby = DEFAULT; /* -m | -r */ +static char *nlistf = _PATH_DEVNULL; /* -N | -n */ +static pid_t *pids; /* -p | -p */ +static int npids; /* ditto */ +static dev_t *devs; /* -T or -t | -t */ +static int ndevs; /* ditto */ +static uid_t *uids; /* -U | -u */ +static int nuids; /* ditto */ +#if defined(COMPAT_SUSV2) +static uid_t *ruids; /* nop | -U */ +static int nruids; /* ditto */ +static gid_t *gids; /* nop | -G */ +static int ngids; /* ditto */ +#endif +static char *swapf = _PATH_DEVNULL; /* -W | -w */ +static int dropgid; /* ditto */ +static int xflag; /* -x | -A or -e */ -enum sort { DEFAULT, SORTMEM, SORTCPU } sortby = DEFAULT; - -static char *fmt __P((char **(*)(kvm_t *, const struct kinfo_proc *, int), - KINFO *, char *, int)); -static char *kludge_oldps_options __P((char *)); -static int pscomp __P((const void *, const void *)); -static void saveuser __P((KINFO *)); -static void scanvars __P((void)); -static void dynsizevars __P((KINFO *)); -static void sizevars __P((void)); -static void usage __P((void)); -static uid_t *getuids(const char *, int *); - -char dfmt[] = "pid tt state time command"; -char jfmt[] = "user pid ppid pgid sess jobc state tt time command"; -char lfmt[] = "uid pid ppid cpu pri nice vsz rss wchan state tt time command"; -char o1[] = "pid"; -char o2[] = "tt state time command"; -char ufmt[] = "user pid %cpu %mem vsz rss tt state start time command"; -char vfmt[] = "pid state time sl re pagein vsz rss lim tsiz %cpu %mem command"; +static struct winsize ws; +static int needuser, needcomm; /* scanvars() */ -kvm_t *kd; +/* + * Local functions + */ +static void addentry __P((char *, void **, int *, enum entry)); +static void dynsizevars __P((KINFO *)); +static char *fmt __P((kvm_t *, + char **(*)(kvm_t *, const struct kinfo_proc *, int), + KINFO *, char *, int)); +static char *kludge_oldps_options __P((char *)); +static void bsd_parseopts __P((int, char *const *)); +#if defined(COMPAT_SUSV2) +static void susv2_parseopts __P((int, char *const *)); +#endif +static int pscomp __P((const void *, const void *)); +static void saveuser __P((kvm_t *, KINFO *)); +static void scanvars __P((void)); +static void sizevars __P((void)); +static void usage __P((void)); int main(argc, argv) int argc; char *argv[]; { - struct kinfo_proc *kp; - struct varent *vent; - struct winsize ws; - dev_t ttydev; - pid_t pid; - uid_t *uids; - int all, ch, flag, i, fmt, lineno, nentries, dropgid; - int prtheader, wflag, what, xflg, uid, nuids; - char *nlistf, *memf, errbuf[_POSIX2_LINE_MAX]; + kvm_t *kd; /* kvm file descriptor */ + struct kinfo_proc *kp; /* kvm_getprocs() */ + VARENT *vent; + int i, j, lineno; /* indices */ + int what, flag, nentries; /* kvm_getprocs() */ + char errbuf[_POSIX2_LINE_MAX]; /* kvm_openfiles() */ +#if defined(COMPAT_SUSV2) + char *cp; +#endif (void) setlocale(LC_ALL, ""); @@ -138,52 +193,340 @@ else termwidth = ws.ws_col - 1; +#if defined(COMPAT_SUSV2) + if ((cp = strrchr(argv[0], '/')) != NULL) + cp++; + else + cp = argv[0]; + susv2 = strchr(cp, '5') != NULL; + if ((cp = getenv(SUSV2ENV)) != NULL) + susv2 = atoi(cp); /* XXX ERANGE */ +#endif + if (argc > 1) argv[1] = kludge_oldps_options(argv[1]); - all = fmt = prtheader = wflag = xflg = 0; - pid = -1; - nuids = 0; - uids = NULL; - ttydev = NODEV; - dropgid = 0; - memf = nlistf = _PATH_DEVNULL; - while ((ch = getopt(argc, argv, +#if defined(COMPAT_SUSV2) + if (susv2) + susv2_parseopts(argc, argv); + else +#endif + bsd_parseopts(argc, argv); + + argc -= optind; + argv += optind; + +#ifdef BACKWARD_COMPATIBILITY +#if defined(COMPAT_SUSV2) + if (!susv2) +#endif + if (*argv) { + nlistf = *argv; + if (*++argv) { + memf = *argv; +#if defined(NO_SWAP) + if (*++argv) + swapf = *argv; +#endif + } + } +#endif + /* + * Discard setgid privileges if not the running kernel so that bad + * guys can't print interesting stuff from kernel memory. + */ + if (dropgid) { + setgid(getgid()); + setuid(getuid()); + } + + kd = kvm_openfiles(nlistf, memf, swapf, O_RDONLY, errbuf); + if (kd == 0) + errx(1, "%s", errbuf); + + /* XXX - should be cleaner */ + if (!all + && !(nuids + npids + ndevs) +#if defined(COMPAT_SUSV2) + && !(ngids + npgids + nruids + ncmds) +#endif + ) { + char buf[UIDLEN]; + + snprintf(buf, sizeof(buf), "%d", getuid()); + addentry(buf, (void **)&uids, &nuids, UID); + } + + /* + * scan requested variables, noting what structures are needed, + * and adjusting header widths as appropriate. + */ + scanvars(); + + /* + * get proc list + */ + if (nuids == 1) { + what = KERN_PROC_UID; + flag = *uids; + } else if (npids == 1) { + what = KERN_PROC_PID; + flag = *pids; + } else if (ndevs == 1) { + what = KERN_PROC_TTY; + flag = *devs; + } +#if defined(COMPAT_SUSV2) + else if (npgids == 1) { + what = KERN_PROC_PGRP; + flag = *pgids; + } else if (nruids == 1) { + what = KERN_PROC_RUID; + flag = *ruids; + } +#endif + else { + what = KERN_PROC_ALL; + flag = 0; + } + + /* + * select procs + */ + if ((kp = kvm_getprocs(kd, what, flag, &nentries)) == 0) + errx(1, "%s", kvm_geterr(kd)); + if ((kinfo = malloc(nentries * sizeof(*kinfo))) == NULL) + err(1, "malloc"); + for (i = nentries; --i >= 0; ++kp) { + kinfo[i].ki_p = kp; + if (needuser) + saveuser(kd, &kinfo[i]); + dynsizevars(&kinfo[i]); + } + + sizevars(); + + /* + * print header + */ + printheader(); + + /* + * oops! no proc, goodbye. + */ + if (nentries == 0) + exit(1); + + /* + * sort proc list + */ + qsort(kinfo, nentries, sizeof(KINFO), pscomp); + + /* + * for each proc, call each variable output function. + */ + for (i = lineno = 0; i < nentries; i++) { + if (xflag == 0 && (KI_EPROC(&kinfo[i])->e_tdev == NODEV || + (KI_PROC(&kinfo[i])->p_flag & P_CONTROLT) == 0)) + continue; + if (nuids > 1) { + for (j = 0; j < nuids; j++) + if (KI_EPROC(&kinfo[i])->e_ucred.cr_uid == + uids[j]) + break; + if (j == nuids) + continue; + } +#if defined(COMPAT_SUSV2) + if (npids > 1) { + for (j = 0; j < npids; j++) + if (KI_PROC(&kinfo[i])->p_pid == pids[j]) + break; + if (j == npids) + continue; + } + if (ndevs > 1) { + for (j = 0; j < ndevs; j++) + if (KI_EPROC(&kinfo[i])->e_tdev == devs[j]) + break; + if (j == ndevs) + continue; + } + if (ngids > 0) { + for (j = 0; j < ngids; j++) + if (KI_EPROC(&kinfo[i])->e_ucred.cr_gid == + gids[j]) + break; + if (j == ngids) + continue; + } + if (npgids > 1) { + for (j = 0; j < npgids; j++) + if (KI_EPROC(&kinfo[i])->e_pgid == pgids[j]) + break; + if (j == npgids) + continue; + } + if (nruids > 1) { + for (j = 0; j < nruids; j++) + if (KI_EPROC(&kinfo[i])->e_pcred.p_ruid == + ruids[j]) + break; + if (j == nruids) + continue; + } + if (ncmds > 0) { + for (j = 0; j < ncmds; j++) + if (!strncmp(KI_PROC(&kinfo[i])->p_comm, + cmds[j], + MIN(MAXCOMLEN, strlen(cmds[j])))) + break; + if (j == ncmds) + continue; + } +#endif + STAILQ_FOREACH(vent, &varlist, list) { + (vent->var->oproc)(&kinfo[i], vent); + if (STAILQ_NEXT(vent, list) != NULL) + (void)putchar(' '); + } + (void)putchar('\n'); + if (prtheader && lineno++ == prtheader - 4) { + (void)putchar('\n'); + printheader(); + lineno = 0; + } + } + /* XXX needed ? */ + free(uids); +#if defined(COMPAT_SUSV2) + free(devs); + free(gids); + free(pids); + free(pgids); + free(ruids); +#endif + + exit(eval); +} + +static void +bsd_parseopts(int argc, char *const *argv) +{ + static char optstr[OPTLEN]; + static char optfmt[] = "%s%s%s%s%s"; + static char *opts = "aCceghjLlM:mN:O:o:p:rSTt:U:uvwx"; #if defined(LAZY_PS) - "aCcefghjLlM:mN:O:o:p:rSTt:U:uvwx")) != -1) + static char optf[] = "f"; +#else + static char optf[] = ""; +#endif +#if defined(COMPAT_SUSV2) + static char optb[] = "B"; + static char optv[] = "V"; #else - "aCceghjLlM:mN:O:o:p:rSTt:U:uvwx")) != -1) + static char optb[] = ""; + static char optv[] = ""; #endif - switch((char)ch) { +#if defined(NO_SWAP) + static char optw[] = ""; +#else + static char optw[] = "W:"; +#endif + static char o1fmt[] = "pid"; + static char o2fmt[] = "tt state time command"; +#if defined(COMPAT_BSD44) + static char dfmt[] = "pid tt state time command"; + static char jfmt[] = "\ +user pid ppid pgid sess jobc state tt time command"; + static char lfmt[] = "\ +uid pid ppid cpu pri nice vsz rss wchan state tt time command"; + static char ufmt[] = "\ +user pid %cpu %mem vsz rss tt state start time command"; + static char vfmt[] = "\ +pid state time sl re pagein vsz rss lim tsiz %cpu %mem command"; +#else + static char fmt[] = "\ +user[ju] uid[l] pid[djl1uv] ppid[jl] pgid[j] sess[j] jobc[j] cpu[l] \ +pri[l] nice[l] %cpu[u] %mem[u] vsz[lu] rss[lu] wchan[l] tt[d2u] \ +state[djl2uv] tt[jl] start[u] time[djl2uv] sl[v] re[v] pagein[v] \ +vsz[v] rss[v] lim[v] tsiz[v] %cpu[v] %mem[v] command[djl2uv]"; +#endif + + int ch; +#if defined(COMPAT_BSD44) + int fmt; +#else + int jflag; /* -j */ + int lflag; /* -l */ + int uflag; /* -u */ + int vflag; /* -v */ + int oflag; /* -O or -o */ + char *ufmt; /* ditto */ + int nufmt; +#endif + int wflag; /* -w */ + +#if defined(COMPAT_BSD44) + fmt = 0; +#else + jflag = lflag = oflag = uflag = vflag = nufmt = 0; + ufmt = NULL; +#endif + wflag = 0; + + (void)snprintf(optstr, sizeof(optstr), optfmt, + opts, optb, optf, optv, optw); + + while ((ch = getopt(argc, argv, optstr)) != -1) + switch(ch) { case 'a': all = 1; break; +#if defined(COMPAT_SUSV2) + case 'B': /* no-op */ + break; +#endif case 'C': rawcpu = 1; break; case 'c': cflag = 1; break; - case 'e': /* XXX set ufmt */ + case 'e': /* XXX set ufmt */ needenv = 1; break; - case 'g': - break; /* no-op */ +#if defined(LAZY_PS) + case 'f': + if (getuid() == 0 || getgid() == 0) + forceuread = 1; + break; +#endif + case 'g': /* no-op */ + break; case 'h': prtheader = ws.ws_row > 5 ? ws.ws_row : 22; break; case 'j': - parsefmt(jfmt); - fmt = 1; +#if defined(COMPAT_BSD44) + bsd_parsefmt(jfmt); jfmt[0] = '\0'; + fmt = 1; +#else + jflag = 1; +#endif break; case 'L': showkey(); exit(0); case 'l': - parsefmt(lfmt); - fmt = 1; +#if defined(COMPAT_BSD44) + bsd_parsefmt(lfmt); lfmt[0] = '\0'; + fmt = 1; +#else + lflag = 1; +#endif break; case 'M': memf = optarg; @@ -197,25 +540,37 @@ dropgid = 1; break; case 'O': - parsefmt(o1); - parsefmt(optarg); - parsefmt(o2); - o1[0] = o2[0] = '\0'; +#if defined(COMPAT_BSD44) + bsd_parsefmt(o1fmt); + bsd_parsefmt(optarg); + bsd_parsefmt(o2fmt); + o1fmt[0] = o2fmt[0] = '\0'; fmt = 1; +#else + /* XXX quick and dirty hack, need to be rewritten */ + if (o1fmt[0]) { + addentry(o1fmt, (void **)&ufmt, &nufmt, FMT); + o1fmt[0] = '\0'; + } + addentry(optarg, (void **)&ufmt, &nufmt, FMT); + oflag = 1; +#endif break; case 'o': - parsefmt(optarg); +#if defined(COMPAT_BSD44) + bsd_parsefmt(optarg); fmt = 1; - break; -#if defined(LAZY_PS) - case 'f': - if (getuid() == 0 || getgid() == 0) - forceuread = 1; - break; +#else + addentry(optarg, (void **)&ufmt, &nufmt, FMT); + oflag = 1; #endif + break; case 'p': - pid = atol(optarg); - xflg = 1; +#if defined(COMPAT_BSD44) + npids = 0; +#endif + addentry(optarg, (void **)&pids, &npids, PID); + xflag = 1; break; case 'r': sortby = SORTCPU; @@ -228,217 +583,465 @@ errx(1, "stdin: not a terminal"); /* FALLTHROUGH */ case 't': { - struct stat sb; - char *ttypath, pathbuf[PATH_MAX]; - - if (strcmp(optarg, "co") == 0) - ttypath = _PATH_CONSOLE; - else if (*optarg != '/') - (void)snprintf(ttypath = pathbuf, - sizeof(pathbuf), "%s%s", _PATH_TTY, optarg); - else - ttypath = optarg; - if (stat(ttypath, &sb) == -1) - err(1, "%s", ttypath); - if (!S_ISCHR(sb.st_mode)) - errx(1, "%s: not a terminal", ttypath); - ttydev = sb.st_rdev; +#if defined(COMPAT_BSD44) + ndevs = 0; +#endif + addentry(optarg, (void **)&devs, &ndevs, DEV); break; } case 'U': - uids = getuids(optarg, &nuids); - xflg++; /* XXX: intuitive? */ +#if defined(COMPAT_BSD44) + nuids = 0; +#endif + addentry(optarg, (void **)&uids, &nuids, UID); + xflag = 1; /* XXX intuitive? */ break; case 'u': - parsefmt(ufmt); sortby = SORTCPU; - fmt = 1; +#if defined(COMPAT_BSD44) + bsd_parsefmt(ufmt); ufmt[0] = '\0'; + fmt = 1; +#else + uflag = 1; +#endif break; +#if defined(COMPAT_SUSV2) + case 'V': + susv2 = 1; + susv2_parseopts(argc, argv); + return; +#endif case 'v': - parsefmt(vfmt); sortby = SORTMEM; - fmt = 1; +#if defined(COMPAT_BSD44) + bsd_parsefmt(vfmt); vfmt[0] = '\0'; + fmt = 1; +#else + vflag = 1; +#endif break; +#if defined(NO_SWAP) + case 'W': + swapf = optarg; + dropgid = 1; + break; +#endif case 'w': if (wflag) termwidth = UNLIMITED; else if (termwidth < 131) termwidth = 131; - wflag++; + wflag = 1; break; case 'x': - xflg = 1; + xflag = 1; break; case '?': default: usage(); } - argc -= optind; - argv += optind; -#define BACKWARD_COMPATIBILITY -#ifdef BACKWARD_COMPATIBILITY - if (*argv) { - nlistf = *argv; - if (*++argv) { - memf = *argv; +#if defined(COMPAT_BSD44) + if (!fmt) + bsd_parsefmt(dfmt); +#else + if (oflag) { + if (!o1fmt[0]) { + addentry(o2fmt, (void **)&ufmt, &nufmt, FMT); + o2fmt[0] = '\0'; } + susv2_parsefmt(ufmt, NULL); + free(ufmt); /* XXX needed? */ + } else { + char flags[5]; /* jluv\0 | d\0 */ + char *cp; + + cp = flags; + if (jflag) + *cp++ = 'j'; + if (lflag) + *cp++ = 'l'; + if (uflag) + *cp++ = 'u'; + if (vflag) + *cp++ = 'v'; + if (cp == flags) + *cp++ = 'd'; + *cp = '\0'; + susv2_parsefmt(fmt, flags); } #endif - /* - * Discard setgid privileges if not the running kernel so that bad - * guys can't print interesting stuff from kernel memory. - */ - if (dropgid) { - setgid(getgid()); - setuid(getuid()); - } +} - kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf); - if (kd == 0) - errx(1, "%s", errbuf); +#if defined(COMPAT_SUSV2) +static void +susv2_parseopts(int argc, char *const *argv) +{ + static char *opts = "AaBC:defg:G:jLlm:n:o:p:t:u:U:Vw:"; + static char fmt[] = "\ +f[lx] s[lx] user[fx] uid[l] pid[dfjlx] ppid[flx] pgid[j] sid[j] \ +c[flx] pri[lx] nice[lx] addr[lx] vsz[lx] wchan[lx] stime[fx] \ +tt[dfjlx] time[dfjlx] comm[djl] args[fx]"; /* x means both f and l */ + + int ch; + int fflag = 0; /* -f */ + int jflag = 0; /* -j */ + int lflag = 0; /* -l */ + int oflag = 0; /* -o */ + char *ufmt; /* ditto */ + int nufmt; + + fflag = jflag = lflag = oflag = nufmt = 0; + ufmt = NULL; + + while ((ch = getopt(argc, argv, opts)) != -1) + switch(ch) { + case 'A': + xflag = 1; + break; + case 'a': + all = 1; + break; + case 'B': + susv2 = 0; + bsd_parseopts(argc, argv); + return; + case 'C': + addentry(optarg, (void **)&cmds, &ncmds, CMD); + all = xflag = 1; + break; +#if 0 + case 'c': /* not yet */ + break; +#endif + case 'd': + all = 1; + break; + case 'e': + all = xflag = 1; + break; + case 'f': + fflag = 1; + termwidth = UNLIMITED; + break; + case 'g': + addentry(optarg, (void **)&pgids, &npgids, PGID); + all = xflag = 1; + break; + case 'G': + addentry(optarg, (void **)&gids, &ngids, GID); + break; + case 'j': + jflag = 1; + break; + case 'L': + showkey(); + exit(0); + case 'l': + lflag = 1; + break; + case 'm': + memf = optarg; + dropgid = 1; + break; + case 'n': + nlistf = optarg; + dropgid = 1; + break; + case 'o': + addentry(optarg, (void **)&ufmt, &nufmt, FMT); + oflag = 1; + break; + case 'p': + addentry(optarg, (void **)&pids, &npids, PID); + break; + case 't': + addentry(optarg, (void **)&devs, &ndevs, DEV); + break; + case 'u': + addentry(optarg, (void **)&uids, &nuids, UID); + break; + case 'U': + addentry(optarg, (void **)&ruids, &nruids, UID); + break; + case 'V': /* no-op */ + break; + case 'w': + swapf = optarg; + dropgid = 1; + break; +#if 0 + case 'y': /* not yet */ + break; +#endif + case '?': + default: + usage(); + } - if (!fmt) - parsefmt(dfmt); + if (oflag) { + susv2_parsefmt(ufmt, NULL); + free(ufmt); /* XXX needed? */ + } else { + char flags[3]; /* d\0 | jx\0 */ + char *cp; - /* XXX - should be cleaner */ - if (!all && ttydev == NODEV && pid == -1 && !nuids) { - if ((uids = malloc(sizeof (*uids))) == NULL) - errx(1, "malloc: %s", strerror(errno)); - nuids = 1; - *uids = getuid(); + cp = flags; + if (fflag && lflag) + *cp++ = 'x'; + else if (fflag) + *cp++ = 'f'; + else if (lflag) + *cp++ = 'l'; + if (jflag) + *cp++ = 'j'; + if (cp == flags) + *cp++ = 'd'; + *cp = '\0'; + susv2_parsefmt(fmt, flags); } +} +#endif - /* - * scan requested variables, noting what structures are needed, - * and adjusting header widths as appropriate. - */ - scanvars(); - /* - * get proc list - */ - if (nuids == 1) { - what = KERN_PROC_UID; - flag = *uids; - } else if (ttydev != NODEV) { - what = KERN_PROC_TTY; - flag = ttydev; - } else if (pid != -1) { - what = KERN_PROC_PID; - flag = pid; - } else { - what = KERN_PROC_ALL; - flag = 0; - } - /* - * select procs - */ - if ((kp = kvm_getprocs(kd, what, flag, &nentries)) == 0) - errx(1, "%s", kvm_geterr(kd)); - if ((kinfo = malloc(nentries * sizeof(*kinfo))) == NULL) - err(1, NULL); - for (i = nentries; --i >= 0; ++kp) { - kinfo[i].ki_p = kp; - if (needuser) - saveuser(&kinfo[i]); - dynsizevars(&kinfo[i]); - } +static void +addentry(char *arg, void **entries, int *nentries, enum entry what) +{ + dev_t dev; +#if defined(COMPAT_SUSV2) + char *fmt; + gid_t gid; + pid_t pgid; + char *cmd; +#endif + uid_t uid; + pid_t pid; + size_t len, lo, hi, have, need, size; + struct stat sb; + struct passwd *pwd; +#if defined(COMPAT_SUSV2) + struct group *grp; +#endif + char buf[MAX(UT_NAMESIZE + 1, PATH_MAX)]; + char *ttypath, pathbuf[PATH_MAX]; - sizevars(); + dev = 0; uid = 0; pid = 0; size = 0; /* make gcc happy */ +#if defined(COMPAT_SUSV2) + gid = 0; pgid = 0; fmt = 0; /* ditto */ +#endif - /* - * print header - */ - printheader(); - if (nentries == 0) - exit(1); - /* - * sort proc list - */ - qsort(kinfo, nentries, sizeof(KINFO), pscomp); - /* - * for each proc, call each variable output function. - */ - for (i = lineno = 0; i < nentries; i++) { - if (xflg == 0 && (KI_EPROC(&kinfo[i])->e_tdev == NODEV || - (KI_PROC(&kinfo[i])->p_flag & P_CONTROLT ) == 0)) - continue; - if (nuids > 1) { - for (uid = 0; uid < nuids; uid++) - if (KI_EPROC(&kinfo[i])->e_ucred.cr_uid == - uids[uid]) - break; - if (uid == nuids) + for (; (len = strcspn(arg, SEP)) > 0; + arg += len + strspn(arg + len, SEP)) { + have = *nentries; + need = 1; + + switch (what) { + case DEV: + if ((len + (strlen(_PATH_TTY) * *arg != '/')) + >= sizeof(buf)) { + warnx("%.*s: path name too long", + (int)len, arg); continue; - } - for (vent = vhead; vent; vent = vent->next) { - (vent->var->oproc)(&kinfo[i], vent); - if (vent->next != NULL) - (void)putchar(' '); - } - (void)putchar('\n'); - if (prtheader && lineno++ == prtheader - 4) { - (void)putchar('\n'); - printheader(); - lineno = 0; - } - } - free(uids); + } + strncpy(buf, arg, len); + buf[len] = '\0'; - exit(eval); -} + if (strcmp(buf, "co") == 0) + ttypath = _PATH_CONSOLE; + else if (*buf != '/') + (void)snprintf(ttypath = pathbuf, + sizeof(buf), "%s%s", +#if !defined(COMPAT_BSD44) + !strncmp(buf, "tty", 3) ? _PATH_DEV : +#endif + _PATH_TTY, buf); + else + ttypath = buf; + if (stat(ttypath, &sb) == -1) + err(1, "%s", ttypath); + if (!S_ISCHR(sb.st_mode)) + errx(1, "%s: not a terminal", ttypath); + dev = sb.st_rdev; + size = sizeof(dev_t); + break; +#if defined(COMPAT_SUSV2) + case FMT: + fmt = arg; + size = sizeof(char); + need += len + 1; + break; + case GID: + if (len >= sizeof(buf)) { + warnx("%.*s: group name too long", + (int)len, arg); + continue; + } + strncpy(buf, arg, len); + buf[len] = '\0'; +#if !defined(COMPAT_BSD44) + gid = (gid_t)strtoul(buf, NULL, 10); /* XXX ERANGE */ +#endif -uid_t * -getuids(const char *arg, int *nuids) -{ - char name[UT_NAMESIZE + 1]; - struct passwd *pwd; - uid_t *uids, *moreuids; - int l, alloc; + if ((grp = getgrnam(buf)) == NULL +#if !defined(COMPAT_BSD44) +#if defined(COMPAT_SUSV2) + /* && susv2 */ +#endif + && (grp = getgrgid(gid)) == NULL +#endif + ) { + warnx("%s: no such group", buf); + continue; + } + gid = grp->gr_gid; + size = sizeof(gid); + break; + case PGID: + if (len >= sizeof(buf)) { + warnx("%.*s: process group id too big", + (int)len, arg); + continue; + } + strncpy(buf, arg, len); + buf[len] = '\0'; + + pgid = (pid_t)strtoul(buf, NULL, 10); /* XXX ERANGE */ + size = sizeof(pid_t); + break; + case CMD: + cmd = arg; + size = sizeof(char *); + arg [len++] = '\0'; + break; +#endif + case UID: + if (len >= sizeof(buf)) { + warnx("%.*s: login name too long", + (int)len, arg); + continue; + } + strncpy(buf, arg, len); + buf[len] = '\0'; +#if !defined(COMPAT_BSD44) + uid = (uid_t)strtoul(buf, NULL, 10); /* XXX ERANGE */ +#endif + if ((pwd = getpwnam(buf)) == NULL +#if !defined(COMPAT_BSD44) +#if defined(COMPAT_SUSV2) + /* && susv2 */ +#endif + && (pwd = getpwuid(uid)) == NULL +#endif + ) { + warnx("%s: no such user", buf); + continue; + } + uid = pwd->pw_uid; + size = sizeof(uid); + break; + case PID: + if (len >= sizeof(buf)) { + warnx("%.*s: process id too big", + (int)len, arg); + continue; + } + strncpy(buf, arg, len); + buf[len] = '\0'; - alloc = 0; - *nuids = 0; - uids = NULL; - for (; (l = strcspn(arg, SEP)) > 0; arg += l + strspn(arg + l, SEP)) { - if (l >= sizeof name) { - warnx("%.*s: name too long", l, arg); - continue; + pid = (pid_t)strtoul(buf, NULL, 10); /* XXX ERANGE */ + size = sizeof(pid_t); + break; } - strncpy(name, arg, l); - name[l] = '\0'; - if ((pwd = getpwnam(name)) == NULL) { - warnx("%s: no such user", name); - continue; + + lo = rounddown(have + need, BUCKETS); + hi = roundup2(have, BUCKETS); + if (lo >= hi) { + int n = roundup2(have + need, BUCKETS); + if ((*entries = realloc(*entries, n * size)) == NULL) + err(1, "realloc"); } - if (*nuids >= alloc) { - alloc = (alloc + 1) << 1; - moreuids = realloc(uids, alloc * sizeof (*uids)); - if (moreuids == NULL) { - free(uids); - errx(1, "realloc: %s", strerror(errno)); - } - uids = moreuids; + + switch (what) { + case DEV: + *((dev_t **)entries)[(*nentries)++] = dev; + break; +#if defined(COMPAT_SUSV2) + case FMT: + (*((char **)entries))[(*nentries)++] = ' '; + strncpy((*((char **)entries))+*nentries, fmt, len); + *nentries += len; + (*((char **)entries))[*nentries] = '\0'; + break; + case GID: + (*((gid_t **)entries))[(*nentries)++] = gid; + break; + case PGID: + (*((pid_t **)entries))[(*nentries)++] = pgid; + break; + case CMD: + (*((char ***)entries))[(*nentries)++] = cmd; + break; +#endif + case UID: + (*((uid_t **)entries))[(*nentries)++] = uid; + break; + case PID: + (*((pid_t **)entries))[(*nentries)++] = pid; + break; } - uids[(*nuids)++] = pwd->pw_uid; } - endpwent(); - if (!*nuids) - errx(1, "No users specified"); + switch (what) { + case UID: + endpwent(); + break; +#if defined(COMPAT_SUSV2) + case GID: + endgrent(); + break; + default: /* avoid gcc warnings */ + } +#endif - return uids; + if (!*nentries) { + switch (what) { + case DEV: + arg = "terminal"; + break; +#if defined(COMPAT_SUSV2) + case FMT: + arg = "format"; + break; + case GID: + arg = "group"; + break; + case PGID: + arg = "process group id"; + break; + case CMD: + arg = "process name"; + break; +#endif + case UID: + arg = "user"; + break; + case PID: + arg = "process id"; + break; + } + errx(1, "no %s specified", arg); + } } static void scanvars() { - struct varent *vent; + VARENT *vent; VAR *v; - for (vent = vhead; vent; vent = vent->next) { + STAILQ_FOREACH(vent, &varlist, list) { v = vent->var; if (v->flag & DSIZ) { v->dwidth = v->width; @@ -455,11 +1058,11 @@ dynsizevars(ki) KINFO *ki; { - struct varent *vent; + VARENT *vent; VAR *v; int i; - for (vent = vhead; vent; vent = vent->next) { + STAILQ_FOREACH(vent, &varlist, list) { v = vent->var; if (!(v->flag & DSIZ)) continue; @@ -474,11 +1077,11 @@ static void sizevars() { - struct varent *vent; + VARENT *vent; VAR *v; int i; - for (vent = vhead; vent; vent = vent->next) { + STAILQ_FOREACH(vent, &varlist, list) { v = vent->var; i = strlen(v->header); if (v->width < i) @@ -489,7 +1092,8 @@ } static char * -fmt(fn, ki, comm, maxlen) +fmt(kd, fn, ki, comm, maxlen) + kvm_t *kd; char **(*fn) __P((kvm_t *, const struct kinfo_proc *, int)); KINFO *ki; char *comm; @@ -497,8 +1101,8 @@ { char *s; - if ((s = - fmt_argv((*fn)(kd, ki->ki_p, termwidth), comm, maxlen)) == NULL) + if ((s = fmt_argv((*fn)(kd, ki->ki_p, termwidth), + comm, maxlen)) == NULL) err(1, NULL); return (s); } @@ -506,7 +1110,8 @@ #define UREADOK(ki) (forceuread || (KI_PROC(ki)->p_flag & P_INMEM)) static void -saveuser(ki) +saveuser(kd, ki) + kvm_t *kd; KINFO *ki; { struct usave *usp; @@ -530,7 +1135,7 @@ * save arguments if needed */ if (needcomm && (UREADOK(ki) || (KI_PROC(ki)->p_args != NULL))) { - ki->ki_args = fmt(kvm_getargv, ki, KI_PROC(ki)->p_comm, + ki->ki_args = fmt(kd, kvm_getargv, ki, KI_PROC(ki)->p_comm, MAXCOMLEN); } else if (needcomm) { ki->ki_args = malloc(strlen(KI_PROC(ki)->p_comm) + 3); @@ -539,7 +1144,7 @@ ki->ki_args = NULL; } if (needenv && UREADOK(ki)) { - ki->ki_env = fmt(kvm_getenvv, ki, (char *)NULL, 0); + ki->ki_env = fmt(kd, kvm_getenvv, ki, (char *)NULL, 0); } else if (needenv) { ki->ki_env = malloc(3); strcpy(ki->ki_env, "()"); @@ -548,13 +1153,14 @@ } } +#define VSIZE(k) (KI_EPROC(k)->e_vm.vm_dsize + KI_EPROC(k)->e_vm.vm_ssize + \ + KI_EPROC(k)->e_vm.vm_tsize) + static int pscomp(a, b) const void *a, *b; { int i; -#define VSIZE(k) (KI_EPROC(k)->e_vm.vm_dsize + KI_EPROC(k)->e_vm.vm_ssize + \ - KI_EPROC(k)->e_vm.vm_tsize) if (sortby == SORTCPU) return (getpcpu((KINFO *)b) - getpcpu((KINFO *)a)); @@ -586,12 +1192,16 @@ len = strlen(s); if ((newopts = ns = malloc(len + 2)) == NULL) - err(1, NULL); + err(1, "malloc"); /* * options begin with '-' */ - if (*s != '-') + if (*s != '-') { +#if defined(COMPAT_SUSV2) + susv2 = 0; +#endif *ns++ = '-'; /* add option flag */ + } /* * gaze to end of argv[1] */ @@ -634,10 +1244,42 @@ static void usage() { +#if defined(LAZY_PS) + static char optf[] = "f"; +#else + static char optf[] = ""; +#endif +#if defined(COMPAT_BSD44) + static char list[] = ""; +#else + static char list[] = "list"; +#endif +#if defined(COMPAT_SUSV2) + static char optb[] = "B"; + static char optv[] = "V"; +#else + static char optb[] = ""; + static char optv[] = ""; +#endif +#if defined(NO_SWAP) + static char optw[] = ""; +#else + static char optw[] = " [-W swap]"; +#endif - (void)fprintf(stderr, "%s\n%s\n%s\n", - "usage: ps [-aChjlmrSTuvwx] [-O|o fmt] [-p pid] [-t tty] [-U user]", - " [-M core] [-N system]", - " ps [-L]"); +#if defined(COMPAT_SUSV2) + if (susv2) + (void)fprintf(stderr, "\ +usage: ps [-AaBdefjl] [-C cmdlist] [-g pgrplist] [-G grouplist] [-o fmt]\n\ + [-p pidlist] [-t ttylist] [-u userlist] [-U userlist]\n\ + [-m core] [-n system] [-w swap]\n\ +"); + else +#endif + (void)fprintf(stderr, "\ +usage: ps [-a%sC%shjlmrSTuv%swx] [-O|-o fmt] [-p pid%s] [-t tty%s]\n\ + [-U user%s] [-M core] [-N system]%s\n\ + ps [-L]\n\ +", optb, optf, optv, list, list, list, optw); exit(1); } Index: ps.h =================================================================== RCS file: /home/ncvs/src/bin/ps/ps.h,v retrieving revision 1.7 diff -u -r1.7 ps.h --- ps.h 27 Aug 1999 23:14:52 -0000 1.7 +++ ps.h 3 Jun 2001 20:10:12 -0000 @@ -34,6 +34,10 @@ * $FreeBSD: src/bin/ps/ps.h,v 1.7 1999/08/27 23:14:52 peter Exp $ */ +#if !defined(COMPAT_BSD44) && !defined(COMPAT_SUSV2) +#define COMPAT_BSD44 +#endif + #define UNLIMITED 0 /* unlimited terminal width */ enum type { CHAR, UCHAR, SHORT, USHORT, INT, UINT, LONG, ULONG, KPTR }; @@ -56,8 +60,10 @@ } KINFO; /* Variables. */ +typedef STAILQ_HEAD(varlist, varent) VARLIST; + typedef struct varent { - struct varent *next; + STAILQ_ENTRY(varent) list; struct var *var; } VARENT; --/NkBOFFp2J2Af1nK-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Jun 10 20:24: 0 2002 Delivered-To: freebsd-standards@freebsd.org Received: from smtp.noos.fr (racine.noos.net [212.198.2.71]) by hub.freebsd.org (Postfix) with ESMTP id 85ADD37B40B for ; Mon, 10 Jun 2002 20:23:51 -0700 (PDT) Received: (qmail 8944439 invoked by uid 0); 11 Jun 2002 03:23:50 -0000 Received: from unknown (HELO gits.gits.dyndns.org) ([212.198.230.194]) (envelope-sender ) by 212.198.2.71 (qmail-ldap-1.03) with SMTP for ; 11 Jun 2002 03:23:50 -0000 Received: from gits.gits.dyndns.org (tld3lvtqpggh3udm@localhost [127.0.0.1]) by gits.gits.dyndns.org (8.12.3/8.12.3) with ESMTP id g5B3Nja6016644; Tue, 11 Jun 2002 05:23:45 +0200 (CEST) (envelope-from root@gits.dyndns.org) Received: (from root@localhost) by gits.gits.dyndns.org (8.12.3/8.12.3/Submit) id g5B3Njk5016643; Tue, 11 Jun 2002 05:23:45 +0200 (CEST) (envelope-from root) Date: Tue, 11 Jun 2002 05:23:45 +0200 From: Cyrille Lefevre To: "Tim J. Robbins" Cc: "J. Mallett" , standards@FreeBSD.org Subject: Re: cvs commit: www/en/projects/c99 index.sgml Message-ID: <20020611032345.GC14401@gits.dyndns.org> References: <200206070217.g572HH584853@freefall.freebsd.org> <20020606194448.A23497@FreeBSD.ORG> <20020607123628.A60618@treetop.robbins.dropbear.id.au> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020607123628.A60618@treetop.robbins.dropbear.id.au> User-Agent: Mutt/1.3.99i Organization: ACME X-Face: V|+c;4!|B?E%BE^{E6);aI.[< List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Fri, Jun 07, 2002 at 12:36:28PM +1000, Tim J. Robbins wrote: > On Thu, Jun 06, 2002 at 07:44:49PM -0700, J. Mallett wrote: > > > Which essentially means: If you have patches for ps(1) wrt SUSv3 conformance, > > or want to discuss which options of ours should go in favor of SUSv3 ones that > > conflict, which should be optional, etc., speak up. > > My opinion is that we shouldn't remove the traditional BSD options where > they conflict with the XSI extensions. POSIX.2 UPE conformance would be > a good thing, though. > > Here is the synopsis from P1003.2a: > > 5.23.1 Synopsis > > ps [-aA] [-G grouplist] [-o format] ... [-p proclist] [-t termlist] > [-U userlist] > > We are missing -A and -G, and the -p and -o options may have other problems. that's not so simple. even "compatible" options may differ in their output or whatever. let's try -j, -l, and -u. $ ps -j USER PID PPID PGID SESS JOBC STAT TT TIME COMMAND root 1326 1 74 c0efca80 0 I p0- 0:00.22 /bin/sh /etc/rc.local.n e $ ps -l UID PID PPID CPU PRI NI VSZ RSS WCHAN STAT TT TIME COMMAND 0 1326 1 16 10 0 712 304 wait I p0- 0:00.22 /bin/sh /etc $ ps -u USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND root 16604 0.0 0.5 804 572 v1 R+ 5:15AM 0:00.00 -ksh (ksh) $ ps5 -j ps5: sid: keyword not found PID PGID TT TIME COMMAND 1326 74 p0- 00:00:00 sh (oop! incomplete work, sid is missing, forgot about that) $ ps5 -l F S UID PID PPID C PRI NI ADDR VSZ WCHAN TT TIME COMMAND 86 I 0 1326 1 0 32 0 c84c6ba0 712 wait p0- 00:00:00 sh $ ps5 -u (different meaning) also, the current ps(1) implementation is a lot ugly when combining format options, let's try -lu : $ ps -lu UID PID PPID CPU PRI NI VSZ RSS WCHAN STAT TT TIME COMMAND USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND 0 16635 8064 1 28 0 236 104 - R+ v1 0:00.01 head -2 root 16635 0.0 0.1 236 104 v1 R+ 5:20AM 0:00.01 head -2 compared to : $ ps -Blu USER UID PID PPID CPU PRI NI %CPU %MEM VSZ RSS WCHAN TT STAT START ED TIME COMMAND root 0 16636 8064 2 28 0 0.0 0.3 504 332 - v1 R+ 5:21 AM 0:00.00 ps5 -Blu -B stands for BSD ps(1) option treatment. see my previous post about that. Cyrille. -- Cyrille Lefevre mailto:cyrille.lefevre@laposte.net To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Jun 10 20:24:12 2002 Delivered-To: freebsd-standards@freebsd.org Received: from espresso.q9media.com (espresso.q9media.com [216.254.138.122]) by hub.freebsd.org (Postfix) with ESMTP id D7B2E37B412; Mon, 10 Jun 2002 20:24:02 -0700 (PDT) Received: (from mike@localhost) by espresso.q9media.com (8.11.6/8.11.6) id g5B3Lsn41820; Mon, 10 Jun 2002 23:21:54 -0400 (EDT) (envelope-from mike) Date: Mon, 10 Jun 2002 23:21:54 -0400 From: Mike Barcroft To: Cyrille Lefevre Cc: "J. Mallett" , standards@FreeBSD.org Subject: Re: cvs commit: www/en/projects/c99 index.sgml Message-ID: <20020610232154.D90728@espresso.q9media.com> References: <200206070217.g572HH584853@freefall.freebsd.org> <20020606194448.A23497@FreeBSD.ORG> <20020611030857.GB14401@gits.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020611030857.GB14401@gits.dyndns.org>; from cyrille.lefevre@laposte.net on Tue, Jun 11, 2002 at 05:08:57AM +0200 Organization: The FreeBSD Project Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Cyrille Lefevre writes: > well, I'm a lot disapointed about your nomination while I ask for it last > week. I suppose you get the maintainership of ps(1) because you are > a commiter ? whatever, here is, in attachment, the current version of > ps(1) I'm working on. Changes need to go through a committer anyway, so I thought it would be best if J. Mallett oversaw this. This doesn't mean your code won't end up in ps(1), only that you have a specific committer to interface with. Best regards, Mike Barcroft To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Mon Jun 10 20:24:58 2002 Delivered-To: freebsd-standards@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 931) id 451A237B40C; Mon, 10 Jun 2002 20:24:33 -0700 (PDT) Date: Mon, 10 Jun 2002 20:24:33 -0700 From: Juli Mallett To: Cyrille Lefevre Cc: standards@FreeBSD.org Subject: Re: cvs commit: www/en/projects/c99 index.sgml Message-ID: <20020610202431.A30207@FreeBSD.ORG> References: <200206070217.g572HH584853@freefall.freebsd.org> <20020606194448.A23497@FreeBSD.ORG> <20020611030857.GB14401@gits.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.2.5.1i In-Reply-To: <20020611030857.GB14401@gits.dyndns.org>; from cyrille.lefevre@laposte.net on Tue, Jun 11, 2002 at 05:08:57AM +0200 Organisation: The FreeBSD Project X-Alternate-Addresses: , , , X-Affiliated-Projects: FreeBSD, xMach, ircd-hybrid-7 X-Towel: Yes Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG * Cyrille Lefevre escriurรจres > On Thu, Jun 06, 2002 at 07:44:49PM -0700, J. Mallett wrote: > > * From Mike Barcroft > > > mike 2002/06/06 19:17:17 PDT > > > > > > Modified files: > > > en/projects/c99 index.sgml > > > Log: > > > J. Mallett will be coordinating changes to ps(1). > > > > Which essentially means: If you have patches for ps(1) wrt SUSv3 conformance, > > or want to discuss which options of ours should go in favor of SUSv3 ones that > > conflict, which should be optional, etc., speak up. > > well, I'm a lot disapointed about your nomination while I ask for it last > week. I suppose you get the maintainership of ps(1) because you are > a commiter ? whatever, here is, in attachment, the current version of On the contrary. I am coordinating the changes, because I am a committer, but I did not (I explicitly told mike@ that I did not) want to be in charge of this task. There's a lot of different approaches that could be taken with dealing with ps(1), as it's one of those unpleasent situations where compromises, etc., may be made, and it's important those things aren't in the hands of one single person, and I'm an agreeable person, and as such happy to coordinate to come up with the best conformant ps(1) we can have! :) > ps(1) I'm working on. Thanks. > PS : I've tryed to subscribe to this list twince w/o success, any ideas ? majordomo can be difficult, a message to majordomo@FreeBSD.org with contents of "subscribe freebsd-standaards" or "subscribe standards" should work. > ps compatible pre-BSD44, BSD44 and SUSV2 > > first of all, this code has been made last year and is based on > -stable version of ps(1). since then, I never posted it before > because it's conformance to SUSV2 (now SUSV3) needs to be checked. > this need always to be done and I will do it w/in the next days > (weeks?). in the meantime, I'll write a more detailled note about > differences between BSD and SUSV3 ps(1). also, the manual would > have to be updated to reflect the reallity (any volunteer ? :). The manual page may prove to be one of the least pleasent tasks, as while SUS/POSIX has taken from BSD manpages before, we are not allowed to use their text. > old compilation flags : > > BACKWARD_COMPATIBILITY > convert pre BSD44 options (w/o dash) to BSD44 ones. > > LAZY_PS > enable option -f to show command line and environment > information about swapped out processes else, the -f > option is implied. > > new compilation flags : > > COMPAT_BSD44 > be strictly compatible w/ BSD44 ps, else : > * -p, -t and -U respectively accept a list of pids, ttys > or users instead of a single one. > * -t accept ttyXX in addition to /dev/ttyXX and XX. > * -U also accept uids in addition of user names. > * output is formated more intelligently when combining > options such as -j, -l, -u and -v. format strings are > combined instead of being concatenated. > * -o keyword=header now works for aliased keywords, also, > -o keyword= don't print an empty line anymore, if any. > > COMPAT_SUSV2 > be compatible w/ SUSV2 ps if the SUSV2 environment variable > has a non-zero value or if called as ps5. this may be > overriden using the new -B (BSD) or -V (SUSV2) options. > SUSV2 is automagically disabled when using pre BSD44 options. > SUSV2 options are, in fact, almost the SYSV ones. > > here is the usage string : > > usage: ps [-AaBdefjl] [-C cmdlist] [-g pgrplist] [-G grouplist] [-o fmt] > [-p pidlist] [-t ttylist] [-u userlist] [-U userlist] > [-m core] [-n system] [-w swap] > > here are the new -o keywords w/ their BSD44 counterpart, > if any, in parentheses : > > addr (paddr), args (command), c, comm (command), > etime, group, l (state), rgroup and stime. > and the ones which are affected when SUSV2 is enable : > > pri and time. Why can't these be there by default? > NO_SWAP > disable -W option since kvm(3) doesn't read swap for almost > 10 years. > > also, single-linked tail queues have been converted to queue(3). This is a mixed thing. Some people will rightly say that conversion of a simplistic paradigm of code to the queue(3) constructs can be obfuscatory, and certainly macros which evolved after 4.3BSD sometimes differ in their meaning. TAILQ_FOREACH{,_REVERSE} on OSX bit me particularly hard. > Index: Makefile > =================================================================== > RCS file: /home/ncvs/src/bin/ps/Makefile,v > retrieving revision 1.13 > diff -u -r1.13 Makefile > --- Makefile 17 Nov 1999 13:37:30 -0000 1.13 > +++ Makefile 11 Jun 2002 03:02:38 -0000 > @@ -9,7 +9,12 @@ > # keep ps from being an unnecessary load > # on large systems. > # > -CFLAGS+=-I${.CURDIR}/../../sys -DLAZY_PS > +CFLAGS= -g > +CFLAGS+= -I${.CURDIR}/../../sys > +CFLAGS+= -DBACKWARD_COMPATIBILITY > +CFLAGS+= -DLAZY_PS > +# CFLAGS+= -DCOMPAT_BSD44 > +CFLAGS+= -DCOMPAT_SUSV2 > DPADD= ${LIBM} ${LIBKVM} > LDADD= -lm -lkvm > #BINGRP= kmem There should be a make(1) tunable to handle the SUS compatability so that a system being tested for standards conformance could have a flag such as: POSIX_CONFORM= NOBSD To disable BSD things that conflict with POSIX and use POSIX instead, or: POSIX_CONFORM= NOCONFLICT To use POSIX things where there's no conflict with BSD, but which are not meaningful in BSD (things related to sysv runtimes come to mind). The rest of it looks straightforward in places, but some of the changes look a bit big and I'd like to see what later comes up wrt susv3 and patches to the current version of ps(1). Thanks! -- Juli Mallett FreeBSD: The Power To Serve Perception is prejudice / Don't classify me / Accept me as me / Not what you see To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Jun 11 15:58:34 2002 Delivered-To: freebsd-standards@freebsd.org Received: from scan.ji-net.com (scan.ji-net.com [203.130.156.4]) by hub.freebsd.org (Postfix) with ESMTP id 99F1637B400 for ; Tue, 11 Jun 2002 15:58:32 -0700 (PDT) Received: from net1.ji-net.com ([203.156.15.120]) by scan.ji-net.com (8.11.2/8.11.2) with SMTP id g5BMwTQ24441 for ; Wed, 12 Jun 2002 05:58:29 +0700 Message-Id: <200206112258.g5BMwTQ24441@scan.ji-net.com> Date: Wed, 12 Jun 2002 06:00:32 To: standards@FreeBSD.org From: goodhealthgoodjob@yahoo.com (foodforhealth) Subject: วันนี้คุณดูแลสุขภาพแล้วหรือยัง X-Virus-Scanned: by AMaViS-perl11-milter (http://amavis.org/) Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG แนะนำโปรแกรมควบคุมน้ำหนัก เพิ่มน้ำหนัก รักษาสุขภาพ คุณหรือคนที่คุณรักกำลังมองหาวิธีดูแลสุขภาพที่เป็นธรรมชาติอยู่ใช่ไหม? หากคุณเบื่อหน่ายกับความพยายามที่ไม่ประสบความสำเร็จครั้งแล้วครั้งเล่า ในการดูแลสุขภาพเพื่อรูปร่างที่ดี เรามีโปรแกรมโภชนาการเพื่อสุขภาพ ที่ช่วยคุณได้ สำหรับผู้ที่มีปัญหา น้ำหนักเกินหรืออ้วน, ผอมเกินไป, มีปัญหาสุขภาพ (ผอมแห้งแรงน้อย, พุงห้อยอืดอาด, ขาดความมั่นใจ, โรคภัยถามหา,ใบหน้าเป็นสิว, ผิวพรรณเหี่ยวย่น, คนเล่นกีฬา, คุณป้าวัยทอง, คุณน้องๆ ที่อยากสวย)เป็นผลิตภัณฑ์จากธรรมชาติ 100 % ไม่ใช่ยา ไม่ต้องอดอาหาร ไม่มีผลข้างเคียง ไม่ต้องออกกำลังกาย ฟังดูไม่น่าเชื่อแต่ก็ต้องเชื่อเพราะผ่าน อย.ทุกประเทศที่เข้าไปขายโดยเฉพาะประเทศไทยและอเมริกา ให้สารอาหารครบถ้วน ปรับสมดุลของร่างกายลดไขมันส่วนเกิน รับรองผลภายใน30วันด้วยระบบคืนเงิน100%(แพทย์ผู้คิดค้นอาหารสูตรนี้คือคนที่คิดค้นอาหารให้นักบินอวกาศองค์การนาซ่า) สนใจ ขอคำแนะนำเพิ่มเติมได้ที่ คุณสิริ 01-8901701พบคำตอบสุดท้ายของคุณได้ที่นี่ http://www.smartslender.com/foodforhealth To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Jun 11 18:13:51 2002 Delivered-To: freebsd-standards@freebsd.org Received: from smtp.noos.fr (racine.noos.net [212.198.2.71]) by hub.freebsd.org (Postfix) with ESMTP id 98A7C37B40E for ; Tue, 11 Jun 2002 18:13:34 -0700 (PDT) Received: (qmail 9572501 invoked by uid 0); 12 Jun 2002 01:13:32 -0000 Received: from unknown (HELO gits.gits.dyndns.org) ([212.198.230.194]) (envelope-sender ) by 212.198.2.71 (qmail-ldap-1.03) with SMTP for ; 12 Jun 2002 01:13:32 -0000 Received: from gits.gits.dyndns.org (s2wjesjnn2zdbipc@localhost [127.0.0.1]) by gits.gits.dyndns.org (8.12.3/8.12.3) with ESMTP id g5C1DVa6075524; Wed, 12 Jun 2002 03:13:32 +0200 (CEST) (envelope-from root@gits.dyndns.org) Received: (from root@localhost) by gits.gits.dyndns.org (8.12.3/8.12.3/Submit) id g5C1DUR1075523; Wed, 12 Jun 2002 03:13:30 +0200 (CEST) (envelope-from root) Date: Wed, 12 Jun 2002 03:13:30 +0200 From: Cyrille Lefevre To: Juli Mallett Cc: standards@FreeBSD.org Subject: Re: cvs commit: www/en/projects/c99 index.sgml Message-ID: <20020612011330.GA45415@gits.dyndns.org> References: <200206070217.g572HH584853@freefall.freebsd.org> <20020606194448.A23497@FreeBSD.ORG> <20020611030857.GB14401@gits.dyndns.org> <20020610202431.A30207@FreeBSD.ORG> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20020610202431.A30207@FreeBSD.ORG> User-Agent: Mutt/1.3.99i Organization: ACME X-Face: V|+c;4!|B?E%BE^{E6);aI.[< List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, Jun 10, 2002 at 08:24:33PM -0700, Juli Mallett wrote: > * Cyrille Lefevre escriur=C3?res [snip] > task. There's a lot of different approaches that could be taken with dea= ling > with ps(1), as it's one of those unpleasent situations where compromises,= etc., some of the possible approaches are : 1) a la HPUX : use an environment variable (UNIX95) to deal w/ some standar= d. 2) a la Tru64 or AIX : BSD options aren't dash (-) prefixed. 3) a la SunOS : use different commands located in different paths. 4) yet another approach : use a different command name to deal w/ some stan= dard. 5) try to merge BSD and System V options. in my opinion, this is really possible except by breaking the former or the later standard since similar options may behave differently such as -u (different meaning) or -j (different output). 6) use a command line option to switch from one or the other behaviour. the current implementation complies w/ 1), 2), 4) and 6). > may be made, and it's important those things aren't in the hands of one s= ingle > person, and I'm an agreeable person, and as such happy to coordinate to c= ome ^^^^^^^^^^^^^^^^^^^^^^^^ I'm sure you are :) > up with the best conformant ps(1) we can have! :) >=20 > > ps(1) I'm working on. >=20 > Thanks. you're wecome. > > PS : I've tryed to subscribe to this list twince w/o success, any ideas= ? >=20 > majordomo can be difficult, a message to majordomo@FreeBSD.org with conte= nts > of "subscribe freebsd-standaards" or "subscribe standards" should work. found the problem, I've tryed to subscribe w/ different from (the one in the header) and subscribe (the one in the body) addresses while they MUST be the sames. [snip] > > differences between BSD and SUSV3 ps(1). also, the manual would > > have to be updated to reflect the reallity (any volunteer ? :). >=20 > The manual page may prove to be one of the least pleasent tasks, as while > SUS/POSIX has taken from BSD manpages before, we are not allowed to use > their text. don't know that ! [snip] > > new compilation flags : > >=20 > > COMPAT_BSD44 > > be strictly compatible w/ BSD44 ps, else : > > * -p, -t and -U respectively accept a list of pids, ttys > > or users instead of a single one. > > * -t accept ttyXX in addition to /dev/ttyXX and XX. > > * -U also accept uids in addition of user names. > > * output is formated more intelligently when combining > > options such as -j, -l, -u and -v. format strings are > > combined instead of being concatenated. > > * -o keyword=3Dheader now works for aliased keywords, also, > > -o keyword=3D don't print an empty line anymore, if any. > >=20 > > COMPAT_SUSV2 > > be compatible w/ SUSV2 ps if the SUSV2 environment variable > > has a non-zero value or if called as ps5. this may be > > overriden using the new -B (BSD) or -V (SUSV2) options. > > SUSV2 is automagically disabled when using pre BSD44 options. > > SUSV2 options are, in fact, almost the SYSV ones. > >=20 > > here is the usage string : > >=20 > > usage: ps [-AaBdefjl] [-C cmdlist] [-g pgrplist] [-G grouplist] [-o fmt] > > [-p pidlist] [-t ttylist] [-u userlist] [-U userlist] > > [-m core] [-n system] [-w swap] > >=20 > > here are the new -o keywords w/ their BSD44 counterpart, > > if any, in parentheses : > >=20 > > addr (paddr), args (command), c, comm (command), > > etime, group, l (state), rgroup and stime. > > and the ones which are affected when SUSV2 is enable : > >=20 > > pri and time. forgot `sid' which isn't implemented yet. > Why can't these be there by default? there are, but their output is different from BSD and SystemV. let's try : # ps5 -VO pri,time | head -2 PID PRI TIME TT COMMAND 1326 32 00:00:00 p0- sh # ps5 -BO pri,time | head -2 PID PRI TIME TT STAT COMMAND 1326 10 0:00.53 p0- I /bin/sh /etc/rc.local.netstat PS : just added -O to SystemV options as SUSV3 authorize it on BSD implementations of ps(1). > > NO_SWAP > > disable -W option since kvm(3) doesn't read swap for almost > > 10 years. > >=20 > > also, single-linked tail queues have been converted to queue(3). >=20 > This is a mixed thing. Some people will rightly say that conversion of a > simplistic paradigm of code to the queue(3) constructs can be obfuscatory, > and certainly macros which evolved after 4.3BSD sometimes differ in their > meaning. TAILQ_FOREACH{,_REVERSE} on OSX bit me particularly hard. I do that last year after reading a thread asking to do so. ask O'brien (probably) for details :) > > Index: Makefile > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > > RCS file: /home/ncvs/src/bin/ps/Makefile,v > > retrieving revision 1.13 > > diff -u -r1.13 Makefile > > --- Makefile 17 Nov 1999 13:37:30 -0000 1.13 > > +++ Makefile 11 Jun 2002 03:02:38 -0000 > > @@ -9,7 +9,12 @@ > > # keep ps from being an unnecessary load > > # on large systems. > > # > > -CFLAGS+=3D-I${.CURDIR}/../../sys -DLAZY_PS > > +CFLAGS=3D -g > > +CFLAGS+=3D -I${.CURDIR}/../../sys > > +CFLAGS+=3D -DBACKWARD_COMPATIBILITY > > +CFLAGS+=3D -DLAZY_PS > > +# CFLAGS+=3D -DCOMPAT_BSD44 > > +CFLAGS+=3D -DCOMPAT_SUSV2 > > DPADD=3D ${LIBM} ${LIBKVM} > > LDADD=3D -lm -lkvm > > #BINGRP=3D kmem >=20 > There should be a make(1) tunable to handle the SUS compatability so that since BSD and SystemV ps are really different in some way, it would be better to consider a runtime (evan sysctl, why not ?) tunable to deal w/ SUS compatability than a static make(1) tunable. considering a runtime tunable, the current DEFINES in use are more there to mark the code change than to make a choice between behaviours. w/ COMPAT_BSD44 undefined, -p and such options allow a pidlist and combining -j and such options is done more intelligently than before. w/ COMPAT_SUSV2 define, you may switch from BSD and SUS behaviour. that's all. in other words, I'm really against breaking whatever compatibility using some compromise. > a system being tested for standards conformance could have a flag such > as: > POSIX_CONFORM=3D NOBSD >=20 > To disable BSD things that conflict with POSIX and use POSIX instead, or: > POSIX_CONFORM=3D NOCONFLICT >=20 > To use POSIX things where there's no conflict with BSD, but which are not > meaningful in BSD (things related to sysv runtimes come to mind).=20 IMHO, nothing is not meaningfull in BSD nor nothing is meaningfull in Syste= mV. they just do the same work differently and should continue this way to not broke anything. > The rest of it looks straightforward in places, but some of the changes l= ook > a bit big and I'd like to see what later comes up wrt susv3 and patches t= o the > current version of ps(1). well, I should have run diff -w to reduce the diffs but not so much (64 lines less, that's all). for instance, I've just reprinted all ps(1) manual pages from BSD, SUSV3, HP-UX 11, Tru64 5, Solaris 9 and AIX 5 and will try make a big table of compatibilities against each other with a priority to BSD and SUSV3 of course, then, I could make a good comparison w/ the current code and finish the work :) Cyrille. --=20 Cyrille Lefevre mailto:cyrille.lefevre@laposte.net To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Jun 11 18:15:45 2002 Delivered-To: freebsd-standards@freebsd.org Received: from smtp.noos.fr (zola.noos.net [212.198.2.76]) by hub.freebsd.org (Postfix) with ESMTP id 1825A37B40C for ; Tue, 11 Jun 2002 18:15:39 -0700 (PDT) Received: (qmail 25817519 invoked by uid 0); 12 Jun 2002 01:15:37 -0000 Received: from unknown (HELO gits.gits.dyndns.org) ([212.198.230.194]) (envelope-sender ) by 212.198.2.76 (qmail-ldap-1.03) with SMTP for ; 12 Jun 2002 01:15:37 -0000 Received: from gits.gits.dyndns.org (4m8d05t1zz4ne5lg@localhost [127.0.0.1]) by gits.gits.dyndns.org (8.12.3/8.12.3) with ESMTP id g5C1FXa6075917; Wed, 12 Jun 2002 03:15:37 +0200 (CEST) (envelope-from root@gits.dyndns.org) Received: (from root@localhost) by gits.gits.dyndns.org (8.12.3/8.12.3/Submit) id g5C1FXwD075916; Wed, 12 Jun 2002 03:15:33 +0200 (CEST) (envelope-from root) Date: Wed, 12 Jun 2002 03:15:33 +0200 From: Cyrille Lefevre To: Mike Barcroft Cc: "J. Mallett" , standards@FreeBSD.org Subject: Re: cvs commit: www/en/projects/c99 index.sgml Message-ID: <20020612011533.GB45415@gits.dyndns.org> References: <200206070217.g572HH584853@freefall.freebsd.org> <20020606194448.A23497@FreeBSD.ORG> <20020611030857.GB14401@gits.dyndns.org> <20020610232154.D90728@espresso.q9media.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020610232154.D90728@espresso.q9media.com> User-Agent: Mutt/1.3.99i Organization: ACME X-Face: V|+c;4!|B?E%BE^{E6);aI.[< List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Mon, Jun 10, 2002 at 11:21:54PM -0400, Mike Barcroft wrote: > Cyrille Lefevre writes: > > well, I'm a lot disapointed about your nomination while I ask for it last > > week. I suppose you get the maintainership of ps(1) because you are > > a commiter ? whatever, here is, in attachment, the current version of > > ps(1) I'm working on. > > Changes need to go through a committer anyway, so I thought it would > be best if J. Mallett oversaw this. This doesn't mean your code won't I understood that, it's just that it was a surprise to see it in an informal message w/o any comments. > end up in ps(1), only that you have a specific committer to interface > with. see you. cyrille. -- Cyrille Lefevre mailto:cyrille.lefevre@laposte.net To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Jun 11 18:44:46 2002 Delivered-To: freebsd-standards@freebsd.org Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (Postfix) with ESMTP id 1C83837B40A for ; Tue, 11 Jun 2002 18:44:44 -0700 (PDT) Received: from khavrinen.lcs.mit.edu (localhost [IPv6:::1]) by khavrinen.lcs.mit.edu (8.12.3/8.12.3) with ESMTP id g5C1ihDK095186; Tue, 11 Jun 2002 21:44:43 -0400 (EDT) (envelope-from wollman@khavrinen.lcs.mit.edu) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.12.3/8.12.3/Submit) id g5C1ihUh095183; Tue, 11 Jun 2002 21:44:43 -0400 (EDT) (envelope-from wollman) Date: Tue, 11 Jun 2002 21:44:43 -0400 (EDT) From: Garrett Wollman Message-Id: <200206120144.g5C1ihUh095183@khavrinen.lcs.mit.edu> To: Cyrille Lefevre Cc: standards@FreeBSD.ORG Subject: Re: cvs commit: www/en/projects/c99 index.sgml In-Reply-To: <20020612011330.GA45415@gits.dyndns.org> References: <200206070217.g572HH584853@freefall.freebsd.org> <20020606194448.A23497@FreeBSD.ORG> <20020611030857.GB14401@gits.dyndns.org> <20020610202431.A30207@FreeBSD.ORG> <20020612011330.GA45415@gits.dyndns.org> Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG < said: > some of the possible approaches are : > 1) a la HPUX : use an environment variable (UNIX95) to deal w/ some standard. > 2) a la Tru64 or AIX : BSD options aren't dash (-) prefixed. > 3) a la SunOS : use different commands located in different paths. > 4) yet another approach : use a different command name to deal w/ some standard. > 5) try to merge BSD and System V options. in my opinion, this is really > possible except by breaking the former or the later standard since > similar options may behave differently such as -u (different meaning) > or -j (different output). > 6) use a command line option to switch from one or the other behaviour. 7) Ignore the losing System V `ps' and leave well enough alone. We have a `ps' that works, behaves the way users expect it, and has never in its history accepted System V options. -GAWollman To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Jun 11 19:14:40 2002 Delivered-To: freebsd-standards@freebsd.org Received: from gw.nectar.cc (gw.nectar.cc [208.42.49.153]) by hub.freebsd.org (Postfix) with ESMTP id B982D37B405; Tue, 11 Jun 2002 19:14:38 -0700 (PDT) Received: by gw.nectar.cc (Postfix, from userid 1001) id C735B43; Tue, 11 Jun 2002 21:14:37 -0500 (CDT) Date: Tue, 11 Jun 2002 21:14:37 -0500 From: "Jacques A. Vidrine" To: Cyrille Lefevre Cc: Juli Mallett , standards@FreeBSD.org Subject: Re: cvs commit: www/en/projects/c99 index.sgml Message-ID: <20020612021437.GA49734@hellblazer.nectar.cc> References: <200206070217.g572HH584853@freefall.freebsd.org> <20020606194448.A23497@FreeBSD.ORG> <20020611030857.GB14401@gits.dyndns.org> <20020610202431.A30207@FreeBSD.ORG> <20020612011330.GA45415@gits.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020612011330.GA45415@gits.dyndns.org> User-Agent: Mutt/1.3.27i X-Url: http://www.nectar.cc/ Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, Jun 12, 2002 at 03:13:30AM +0200, Cyrille Lefevre wrote: > 3) a la SunOS : use different commands located in different paths. /usr/svr4, anyone? *smirk* -- Jacques A. Vidrine http://www.nectar.cc/ NTT/Verio SME . FreeBSD UNIX . Heimdal Kerberos jvidrine@verio.net . nectar@FreeBSD.org . nectar@kth.se To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Jun 11 19:16:21 2002 Delivered-To: freebsd-standards@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 931) id 9B98D37B401; Tue, 11 Jun 2002 19:16:18 -0700 (PDT) Date: Tue, 11 Jun 2002 19:16:18 -0700 From: Juli Mallett To: "Jacques A. Vidrine" Cc: Cyrille Lefevre , standards@FreeBSD.org Subject: Re: cvs commit: www/en/projects/c99 index.sgml Message-ID: <20020611191618.A16249@FreeBSD.ORG> References: <200206070217.g572HH584853@freefall.freebsd.org> <20020606194448.A23497@FreeBSD.ORG> <20020611030857.GB14401@gits.dyndns.org> <20020610202431.A30207@FreeBSD.ORG> <20020612011330.GA45415@gits.dyndns.org> <20020612021437.GA49734@hellblazer.nectar.cc> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.2.5.1i In-Reply-To: <20020612021437.GA49734@hellblazer.nectar.cc>; from nectar@FreeBSD.org on Tue, Jun 11, 2002 at 09:14:37PM -0500 Organisation: The FreeBSD Project X-Alternate-Addresses: , , , X-Affiliated-Projects: FreeBSD, xMach, ircd-hybrid-7 X-Towel: Yes Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG * "Jacques A. Vidrine" escriurรจres > On Wed, Jun 12, 2002 at 03:13:30AM +0200, Cyrille Lefevre wrote: > > 3) a la SunOS : use different commands located in different paths. > > /usr/svr4, anyone? *smirk* Hey, I'm all for that. But then again I still think BINDIR should be /usr/gnu/bin in src/gnu/usr.bin/Makefile.inc, etc. It wouldn't hurt us to provide more and more compatible versions of various utilities in the base system, where we cannot provide a compatible version inside an existing implementation, especially where standards become an issue. -- Juli Mallett FreeBSD: The Power To Serve Perception is prejudice / Don't classify me / Accept me as me / Not what you see To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Jun 11 21:10:41 2002 Delivered-To: freebsd-standards@freebsd.org Received: from thuvia.demon.co.uk (thuvia.demon.co.uk [193.237.34.248]) by hub.freebsd.org (Postfix) with ESMTP id 5CB4737B404; Tue, 11 Jun 2002 21:10:38 -0700 (PDT) Received: from dotar.thuvia.org (dotar.thuvia.org [10.0.0.4]) by phaidor.thuvia.org (8.11.6/8.11.6) with ESMTP id g5C4AZN30311; Wed, 12 Jun 2002 05:10:36 +0100 (BST) (envelope-from mark@thuvia.demon.co.uk) Received: (from mark@localhost) by dotar.thuvia.org (8.11.6/8.11.6) id g5C4AZC52661; Wed, 12 Jun 2002 05:10:35 +0100 (BST) (envelope-from mark) Date: Wed, 12 Jun 2002 05:10:35 +0100 (BST) From: Mark Valentine Message-Id: <200206120410.g5C4AZC52661@dotar.thuvia.org> In-Reply-To: "Jacques A. Vidrine"'s message of Jun 12, 2:25am X-Mailer: Mail User's Shell (7.2.6 beta(5) 10/07/98) To: nectar@freebsd.org ("Jacques A. Vidrine"), Cyrille Lefevre Subject: Re: cvs commit: www/en/projects/c99 index.sgml Cc: Juli Mallett , standards@freebsd.org Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > From: nectar@freebsd.org ("Jacques A. Vidrine") > Date: Wed 12 Jun, 2002 > Subject: Re: cvs commit: www/en/projects/c99 index.sgml > /usr/svr4, anyone? *smirk* /usr/posix, perhaps. We're not trying to add System V compatibility, we're trying to be standards compliant. Putting /usr/posix/bin at the front of your path would prefer POSIX behaviour to BSD behaviour where there are conflicts. Cheers, Mark. -- Mark Valentine, Thuvia Labs "Tigers will do ANYTHING for a tuna fish sandwich." Mark Valentine uses "We're kind of stupid that way." *munch* *munch* and endorses FreeBSD -- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Jun 11 21:42:20 2002 Delivered-To: freebsd-standards@freebsd.org Received: from espresso.q9media.com (espresso.q9media.com [216.254.138.122]) by hub.freebsd.org (Postfix) with ESMTP id 2496237B406; Tue, 11 Jun 2002 21:42:18 -0700 (PDT) Received: (from mike@localhost) by espresso.q9media.com (8.11.6/8.11.6) id g5C4e1607239; Wed, 12 Jun 2002 00:40:01 -0400 (EDT) (envelope-from mike) Date: Wed, 12 Jun 2002 00:40:01 -0400 From: Mike Barcroft To: Mark Valentine Cc: "Jacques A. Vidrine" , Cyrille Lefevre , Juli Mallett , standards@freebsd.org Subject: Re: cvs commit: www/en/projects/c99 index.sgml Message-ID: <20020612004001.E90728@espresso.q9media.com> References: <200206120410.g5C4AZC52661@dotar.thuvia.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200206120410.g5C4AZC52661@dotar.thuvia.org>; from mark@thuvia.demon.co.uk on Wed, Jun 12, 2002 at 05:10:35AM +0100 Organization: The FreeBSD Project Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Mark Valentine writes: > /usr/posix, perhaps. We're not trying to add System V compatibility, > we're trying to be standards compliant. > > Putting /usr/posix/bin at the front of your path would prefer POSIX > behaviour to BSD behaviour where there are conflicts. I really like this idea. Best regards, Mike Barcroft To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Tue Jun 11 21:47:27 2002 Delivered-To: freebsd-standards@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 931) id A9E8B37B407; Tue, 11 Jun 2002 21:47:23 -0700 (PDT) Date: Tue, 11 Jun 2002 21:47:23 -0700 From: Juli Mallett To: Mike Barcroft Cc: Mark Valentine , "Jacques A. Vidrine" , Cyrille Lefevre , standards@freebsd.org Subject: Re: cvs commit: www/en/projects/c99 index.sgml Message-ID: <20020611214723.B31801@FreeBSD.ORG> References: <200206120410.g5C4AZC52661@dotar.thuvia.org> <20020612004001.E90728@espresso.q9media.com> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.2.5.1i In-Reply-To: <20020612004001.E90728@espresso.q9media.com>; from mike@freebsd.org on Wed, Jun 12, 2002 at 12:40:01AM -0400 Organisation: The FreeBSD Project X-Alternate-Addresses: , , , X-Affiliated-Projects: FreeBSD, xMach, ircd-hybrid-7 X-Towel: Yes Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG * Mike Barcroft escriurรจres > Mark Valentine writes: > > /usr/posix, perhaps. We're not trying to add System V compatibility, > > we're trying to be standards compliant. > > > > Putting /usr/posix/bin at the front of your path would prefer POSIX > > behaviour to BSD behaviour where there are conflicts. > > I really like this idea. So do I. Does this mean we should start considering src/posix/{bin,sbin,...} or will we just use LINKS and such? The important question also is whether -arch would agree that it's a good idea :) -- Juli Mallett FreeBSD: The Power To Serve Perception is prejudice / Don't classify me / Accept me as me / Not what you see To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Wed Jun 12 0:39:30 2002 Delivered-To: freebsd-standards@freebsd.org Received: from treetop.robbins.dropbear.id.au (114.b.002.mel.iprimus.net.au [203.134.134.114]) by hub.freebsd.org (Postfix) with ESMTP id 64A5437B408; Wed, 12 Jun 2002 00:39:20 -0700 (PDT) Received: from treetop.robbins.dropbear.id.au (localhost [127.0.0.1]) by treetop.robbins.dropbear.id.au (8.12.2/8.12.2) with ESMTP id g5C7WnBF068887; Wed, 12 Jun 2002 17:32:49 +1000 (EST) (envelope-from tim@treetop.robbins.dropbear.id.au) Received: (from tim@localhost) by treetop.robbins.dropbear.id.au (8.12.2/8.12.2/Submit) id g5C7WmqW068886; Wed, 12 Jun 2002 17:32:48 +1000 (EST) Date: Wed, 12 Jun 2002 17:32:48 +1000 From: "Tim J. Robbins" To: Juli Mallett Cc: standards@FreeBSD.org Subject: Re: cvs commit: www/en/projects/c99 index.sgml Message-ID: <20020612173248.A68800@treetop.robbins.dropbear.id.au> References: <200206070217.g572HH584853@freefall.freebsd.org> <20020606194448.A23497@FreeBSD.ORG> <20020611030857.GB14401@gits.dyndns.org> <20020610202431.A30207@FreeBSD.ORG> <20020612011330.GA45415@gits.dyndns.org> <20020612021437.GA49734@hellblazer.nectar.cc> <20020611191618.A16249@FreeBSD.ORG> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.2.5.1i In-Reply-To: <20020611191618.A16249@FreeBSD.ORG>; from jmallett@FreeBSD.org on Tue, Jun 11, 2002 at 07:16:18PM -0700 Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Tue, Jun 11, 2002 at 07:16:18PM -0700, Juli Mallett wrote: > * "Jacques A. Vidrine" escriurรจres > > On Wed, Jun 12, 2002 at 03:13:30AM +0200, Cyrille Lefevre wrote: > > > 3) a la SunOS : use different commands located in different paths. > > > > /usr/svr4, anyone? *smirk* > > Hey, I'm all for that. But then again I still think BINDIR should be > /usr/gnu/bin in src/gnu/usr.bin/Makefile.inc, etc. > > It wouldn't hurt us to provide more and more compatible versions of various > utilities in the base system, where we cannot provide a compatible version > inside an existing implementation, especially where standards become an issue. Such a corse-grained solution would work well for some utilities, but not for others. Take tail(1) for example. If we are supporting the 1992 POSIX.2 standard, the "+5" in "tail +5 foo" is an option (marked as obsolescent). With P1003.1-2001, though, the "+5" is a filename argument. uniq is another obvious one where +n is used as an option. Some of them don't matter, split/head/expand and more. I think an environment variable is a decent way to solve this problem. The way some of the GNU tools do it, which I happen to agree with, is to check an environment variable "_POSIX2_VERSION", then fall back to the sysconf() variable by the same name. It becomes more complicated when you deal with XSI extensions. I don't know of a clean way of handling that. This has reminded me of a topic I wanted to bring up: are we ever going to set the user.* sysctl variables and their corresponding sysconf()/ confstr() variables? user.posix2_version: 199212 # Should be 200112 ? user.posix2_c_bind: 0 # \ user.posix2_c_dev: 0 # \ user.posix2_char_term: 0 # / Should these be 1 ? user.posix2_fort_dev: 0 # / user.posix2_fort_run: 0 # user.posix2_localedef: 0 user.posix2_sw_dev: 0 # 1 ? user.posix2_upe: 0 # 1 ? We support UPE as well as we # support the rest of the standard. Tim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Wed Jun 12 5: 3:56 2002 Delivered-To: freebsd-standards@freebsd.org Received: from gw.nectar.cc (gw.nectar.cc [208.42.49.153]) by hub.freebsd.org (Postfix) with ESMTP id 99C9A37B40F; Wed, 12 Jun 2002 05:03:53 -0700 (PDT) Received: from madman.nectar.cc (madman.nectar.cc [10.0.1.111]) by gw.nectar.cc (Postfix) with ESMTP id AD98CD; Wed, 12 Jun 2002 07:03:52 -0500 (CDT) Received: from madman.nectar.cc (localhost [IPv6:::1]) by madman.nectar.cc (8.12.3/8.12.3) with ESMTP id g5CC3qJI034289; Wed, 12 Jun 2002 07:03:52 -0500 (CDT) (envelope-from nectar@madman.nectar.cc) Received: (from nectar@localhost) by madman.nectar.cc (8.12.3/8.12.3/Submit) id g5CC3ph9034288; Wed, 12 Jun 2002 07:03:51 -0500 (CDT) Date: Wed, 12 Jun 2002 07:03:51 -0500 From: "Jacques A. Vidrine" To: Mark Valentine Cc: Cyrille Lefevre , Juli Mallett , standards@freebsd.org Subject: Re: cvs commit: www/en/projects/c99 index.sgml Message-ID: <20020612120350.GA34267@madman.nectar.cc> References: <200206120410.g5C4AZC52661@dotar.thuvia.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200206120410.g5C4AZC52661@dotar.thuvia.org> User-Agent: Mutt/1.3.99i X-Url: http://www.nectar.cc/ Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, Jun 12, 2002 at 05:10:35AM +0100, Mark Valentine wrote: > > From: nectar@freebsd.org ("Jacques A. Vidrine") > > Date: Wed 12 Jun, 2002 > > Subject: Re: cvs commit: www/en/projects/c99 index.sgml > > > /usr/svr4, anyone? *smirk* Well, I was kidding here, but... > /usr/posix, perhaps. We're not trying to add System V compatibility, > we're trying to be standards compliant. This has an attraction to it. > Putting /usr/posix/bin at the front of your path would prefer POSIX > behaviour to BSD behaviour where there are conflicts. I don't think we'd need a complete hierarchy... just /usr/posix/ps and so on (much as some OSs have /usr/ccs or /usr/bsd). Cheers, -- Jacques A. Vidrine http://www.nectar.cc/ NTT/Verio SME . FreeBSD UNIX . Heimdal Kerberos jvidrine@verio.net . nectar@FreeBSD.org . nectar@kth.se To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Wed Jun 12 9:25:59 2002 Delivered-To: freebsd-standards@freebsd.org Received: from khavrinen.lcs.mit.edu (khavrinen.lcs.mit.edu [18.24.4.193]) by hub.freebsd.org (Postfix) with ESMTP id 9C05137B403 for ; Wed, 12 Jun 2002 09:25:53 -0700 (PDT) Received: from khavrinen.lcs.mit.edu (localhost [IPv6:::1]) by khavrinen.lcs.mit.edu (8.12.3/8.12.3) with ESMTP id g5CGPqDK099699; Wed, 12 Jun 2002 12:25:52 -0400 (EDT) (envelope-from wollman@khavrinen.lcs.mit.edu) Received: (from wollman@localhost) by khavrinen.lcs.mit.edu (8.12.3/8.12.3/Submit) id g5CGPq0R099696; Wed, 12 Jun 2002 12:25:52 -0400 (EDT) (envelope-from wollman) Date: Wed, 12 Jun 2002 12:25:52 -0400 (EDT) From: Garrett Wollman Message-Id: <200206121625.g5CGPq0R099696@khavrinen.lcs.mit.edu> To: Mark Valentine Cc: standards@FreeBSD.ORG Subject: Re: cvs commit: www/en/projects/c99 index.sgml In-Reply-To: <200206120410.g5C4AZC52661@dotar.thuvia.org> References: <200206120410.g5C4AZC52661@dotar.thuvia.org> Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG < said: > /usr/posix, perhaps. We're not trying to add System V compatibility, > we're trying to be standards compliant. Actually, in a lot of cases, the part of POSIX we don't support is the X/Open System Interfaces (aka Single Unix Spec) option. I am of the belief that it's probably a bad idea to ever claim support for this option, although we may implement many of the interfaces it includes, because so much of it is basically ``standardized SVR4'' and we don't want to be that. (Witness the bogosity with .) -GAWollman To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Wed Jun 12 12:54:14 2002 Delivered-To: freebsd-standards@freebsd.org Received: from smtp.noos.fr (zola.noos.net [212.198.2.76]) by hub.freebsd.org (Postfix) with ESMTP id EA44437B40B for ; Wed, 12 Jun 2002 12:54:08 -0700 (PDT) Received: (qmail 26361573 invoked by uid 0); 12 Jun 2002 19:54:06 -0000 Received: from unknown (HELO gits.gits.dyndns.org) ([212.198.230.194]) (envelope-sender ) by 212.198.2.76 (qmail-ldap-1.03) with SMTP for ; 12 Jun 2002 19:54:06 -0000 Received: from gits.gits.dyndns.org (06m8zxkiwr0yvfsq@localhost [127.0.0.1]) by gits.gits.dyndns.org (8.12.3/8.12.3) with ESMTP id g5CJs5a6033078; Wed, 12 Jun 2002 21:54:05 +0200 (CEST) (envelope-from root@gits.dyndns.org) Received: (from root@localhost) by gits.gits.dyndns.org (8.12.3/8.12.3/Submit) id g5CJs4gI033077; Wed, 12 Jun 2002 21:54:04 +0200 (CEST) (envelope-from root) Date: Wed, 12 Jun 2002 21:54:03 +0200 From: Cyrille Lefevre To: "Jacques A. Vidrine" Cc: Mark Valentine , Juli Mallett , standards@freebsd.org Subject: Re: cvs commit: www/en/projects/c99 index.sgml Message-ID: <20020612195403.GA33037@gits.dyndns.org> References: <200206120410.g5C4AZC52661@dotar.thuvia.org> <20020612120350.GA34267@madman.nectar.cc> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020612120350.GA34267@madman.nectar.cc> User-Agent: Mutt/1.3.99i Organization: ACME X-Face: V|+c;4!|B?E%BE^{E6);aI.[< List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Wed, Jun 12, 2002 at 07:03:51AM -0500, Jacques Vidrine wrote: > On Wed, Jun 12, 2002 at 05:10:35AM +0100, Mark Valentine wrote: [snip] > > /usr/posix, perhaps. We're not trying to add System V compatibility, > > we're trying to be standards compliant. > > This has an attraction to it. > > > Putting /usr/posix/bin at the front of your path would prefer POSIX > > behaviour to BSD behaviour where there are conflicts. > > I don't think we'd need a complete hierarchy... just /usr/posix/ps and how about the future ? who knowns ? > so on (much as some OSs have /usr/ccs or /usr/bsd). not true, SVR4 have /usr/ccs/{bin,include,lib}. isn't it AIX which have /usr/bsd ? Solaris have mixed things like /usr/ucb, /usr/ucb{include,lib} plus /usr/xpg4/{bin,include,lib} and SVR4 ccs. Tru64 have many /usr/XXX/{bin,include,lib} and maybe /usr/ucb ? HP-UX 9 have /bin/posix, but don't remember where this move under HP-UX 10. Cyrille. -- Cyrille Lefevre mailto:cyrille.lefevre@laposte.net To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Wed Jun 12 16: 8: 0 2002 Delivered-To: freebsd-standards@freebsd.org Received: from orthanc.ab.ca (orthanc.ab.ca [216.123.203.186]) by hub.freebsd.org (Postfix) with ESMTP id 8734637B405; Wed, 12 Jun 2002 16:07:56 -0700 (PDT) Received: from orthanc.ab.ca (localhost.orthanc.ab.ca [127.0.0.1]) by orthanc.ab.ca (8.12.3/8.12.3) with ESMTP id g5CN7sJZ001521; Wed, 12 Jun 2002 17:07:55 -0600 (MDT) (envelope-from lyndon@orthanc.ab.ca) Message-Id: <200206122307.g5CN7sJZ001521@orthanc.ab.ca> From: Lyndon Nerenberg Organization: The Frobozz Magic Homing Pigeon Company To: "Tim J. Robbins" Cc: Juli Mallett , standards@FreeBSD.ORG Subject: Re: cvs commit: www/en/projects/c99 index.sgml In-reply-to: Your message of "Wed, 12 Jun 2002 17:32:48 +1000." <20020612173248.A68800@treetop.robbins.dropbear.id.au> X-Mailer: mh-e 5.0.92; MH 6.8.4; Emacs 21.2 Date: Wed, 12 Jun 2002 17:07:54 -0600 Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >>>>> "Tim" == Tim J Robbins writes: Tim> I think an environment variable is a decent way to solve this Tim> problem. The way some of the GNU tools do it, which I happen Tim> to agree with, is to check an environment variable Tim> "_POSIX2_VERSION", then fall back to the sysconf() variable by Tim> the same name. I prefer the environment variable approach. It makes it much easier to control a command's behaviour on a per-invocation basis. --lyndon To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Thu Jun 13 6:15:23 2002 Delivered-To: freebsd-standards@freebsd.org Received: from treetop.robbins.dropbear.id.au (152.d.007.mel.iprimus.net.au [210.50.83.152]) by hub.freebsd.org (Postfix) with ESMTP id 0DDA837B40F for ; Thu, 13 Jun 2002 06:15:19 -0700 (PDT) Received: from treetop.robbins.dropbear.id.au (localhost [127.0.0.1]) by treetop.robbins.dropbear.id.au (8.12.2/8.12.2) with ESMTP id g5DDCbBF069720 for ; Thu, 13 Jun 2002 23:12:37 +1000 (EST) (envelope-from tim@treetop.robbins.dropbear.id.au) Received: (from tim@localhost) by treetop.robbins.dropbear.id.au (8.12.2/8.12.2/Submit) id g5DDCb9J069719 for standards@FreeBSD.ORG; Thu, 13 Jun 2002 23:12:37 +1000 (EST) Date: Thu, 13 Jun 2002 23:12:36 +1000 From: "Tim J. Robbins" To: standards@FreeBSD.ORG Subject: Re: cvs commit: src/usr.bin/wc wc.1 wc.c Message-ID: <20020613231236.A69696@treetop.robbins.dropbear.id.au> References: <200206131248.g5DCmol89972@freefall.freebsd.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <200206131248.g5DCmol89972@freefall.freebsd.org>; from tjr@FreeBSD.ORG on Thu, Jun 13, 2002 at 05:48:50AM -0700 Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Thu, Jun 13, 2002 at 05:48:50AM -0700, Tim J. Robbins wrote: > tjr 2002/06/13 05:48:50 PDT > > Modified files: > usr.bin/wc wc.1 wc.c > Log: > Add the -m option, which counts characters (as opposed to -c, which > counts bytes). In locales that don't have multibyte characters, -m > is effectively an alias for -c. > > This brings wc(1) up to P1003.1-2001 conformance. I had planned to wait until the wide character stdio support was implemented, but I don't think wc(1) would have benefited at all from it. I'm fairly confident that this approach is faster than a fgetwc()-based loop in both single- and multi- byte encodings. There aren't many other utilities that are this simple, so most of the work in supporting multibyte locales will have to wait until wide char stdio is implemented. I feel that supporting wide characters properly is very important as encodings like UTF-8 are becoming quite popular. Tim To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Thu Jun 13 18:10:23 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id B7C8937B413 for ; Thu, 13 Jun 2002 18:10:01 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g5E1A1A32669; Thu, 13 Jun 2002 18:10:01 -0700 (PDT) (envelope-from gnats) Received: from nwww.freebsd.org (www.FreeBSD.org [216.136.204.117]) by hub.freebsd.org (Postfix) with ESMTP id 7B1CF37B437 for ; Thu, 13 Jun 2002 18:00:14 -0700 (PDT) Received: from www.freebsd.org (localhost [127.0.0.1]) by nwww.freebsd.org (8.12.2/8.12.2) with ESMTP id g5E0twhG015125 for ; Thu, 13 Jun 2002 17:55:58 -0700 (PDT) (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.12.2/8.12.2/Submit) id g5E0twZ8015124; Thu, 13 Jun 2002 17:55:58 -0700 (PDT) Message-Id: <200206140055.g5E0twZ8015124@www.freebsd.org> Date: Thu, 13 Jun 2002 17:55:58 -0700 (PDT) From: Jonathan Lennox To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: standards/39256: [v]snprintf aren't POSIX-conformant for strings longer than INT_MAX Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >Number: 39256 >Category: standards >Synopsis: [v]snprintf aren't POSIX-conformant for strings longer than INT_MAX >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Jun 13 18:10:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Jonathan Lennox >Release: 4.3, but verified in -CURRENT sources using cvsweb >Organization: Columbia University >Environment: >Description: POSIX 2001's specification of snprintf specifies that if either the value of n, or the number of bytes required for the format, are greater than INT_MAX, then snprintf should return -1 and set errno to EOVERFLOW. FreeBSD, by contrast, just "clamps" the value of n at INT_MAX. On overflow of the bytes to be converted, it does return -1, but doesn't set errno. Returning EOVERFLOW is an XSI extension, but, I think, a good one. >How-To-Repeat: char buf[80]; int ret = snprintf(buf, (size_t)INT_MAX + 1, "Hello, world!\n"); Expected return: -1, errno = EOVERFLOW. Actual return: snprintf fills in the string "properly". (I didn't actually allocate a buffer of size INT_MAX+1, so this can be demonstrated on mere mortals' computers.) Repeating the problem of the actual buffer is harder, since you need a machine with more than 2 gigabytes of memory. Assuming you have one, though: size_t bufsiz = INT_MAX + 1; char * buf = malloc(bufsiz); int ret; memset(buf, 'a', bufsiz - 1); buf[bufsiz] = '\0'; ret = snprintf(NULL, 0, "%s", buf); Expected result: -1, errno = EOVERFLOW. Actual return: -1, errno undefined. >Fix: Change the test n > INT_MAX in snprintf.c and vsnprintf.c to set errno = EOVERFLOW and return, rather than setting n = INT_MAX. Change __vfprintf to set errno = EOVERFLOW, in addition to returning EOF, if ret + prsize is greater than INT_MAX. >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Fri Jun 14 1:40:32 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id C10FB37B440 for ; Fri, 14 Jun 2002 01:40:06 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g5E8e3n13098; Fri, 14 Jun 2002 01:40:03 -0700 (PDT) (envelope-from gnats) Date: Fri, 14 Jun 2002 01:40:03 -0700 (PDT) Message-Id: <200206140840.g5E8e3n13098@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org Cc: From: Bruce Evans Subject: Re: standards/39256: [v]snprintf aren't POSIX-conformant for strings longer than INT_MAX Reply-To: Bruce Evans Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG The following reply was made to PR standards/39256; it has been noted by GNATS. From: Bruce Evans To: Jonathan Lennox Cc: freebsd-gnats-submit@FreeBSD.ORG Subject: Re: standards/39256: [v]snprintf aren't POSIX-conformant for strings longer than INT_MAX Date: Fri, 14 Jun 2002 18:42:09 +1000 (EST) On Thu, 13 Jun 2002, Jonathan Lennox wrote: > >Description: > POSIX 2001's specification of snprintf specifies that if either the value of n, or the number of bytes required for the format, are greater than INT_MAX, then snprintf should return -1 and set errno to EOVERFLOW. Please keep line lengths somwhat less than 284 characters. This is partly a bug in POSIX. Buffer lengths larger than INT_MAX don't cause any problems unless the string length would be larger than INT_MAX. I think failing for large buffers is incompatible with C99 and plain POSIX (C99 doesn't specify the error handling explicitly, so it is hard to tell). Fortunately, the bug is only in the XSI extensions. > FreeBSD, by contrast, just "clamps" the value of n at INT_MAX. On overflow of the bytes to be converted, it does return -1, but doesn't set errno. Hmm. This is partly an implementation detail in snprintf.c. vfprintf.c returns EOF if the infinite-precision result would be larger than INT_MAX. It doesn't set errno because it was fixed before EOVERFLOW existed and there didn't seem to be any other suitable errno. The clamping is only in snprintf.c. snprintf.c used to have the broken XSI error handling of returning EOF when n > INT_MAX, but was "fixed" by changing to clamping in rev.1.11. Clamping is just an implementation detail, to work around the bug that _size in struct __sbuf has the wrong type (int; should be size_t). Unfortunately, it has an off by one error: if the buffer has size INT_MAX + 1U, then it could hold a string of length INT_MAX, but clamping prevents this and behaviour decays to the XSI spec except for the setting of errno. Clamping gives the correct behaviour for strings that would have length > INT_MAX -- they don't fit, and clamping just results in the overflow being detected one byte earlier than is strictly necessary. > Returning EOVERFLOW is an XSI extension, but, I think, a good one. I agree, but it's not clear how well plain C99 programs would deal with this unexpected errno. > >How-To-Repeat: > char buf[80]; > int ret = snprintf(buf, (size_t)INT_MAX + 1, "Hello, world!\n"); > > Expected return: -1, errno = EOVERFLOW. This gives undefined behaviour since your buffer is shorter than n :-). > Actual return: snprintf fills in the string "properly". (I didn't actually allocate a buffer of size INT_MAX+1, so this can be demonstrated on mere mortals' computers.) > > Repeating the problem of the actual buffer is harder, since you need a machine with more than 2 gigabytes of memory. Assuming you have one, though: Actually, it is easier, since large field widths can be used to reach INT_MAX in just 2 steps. I've deleted all my complete examples of this since I thought that this bug was completely fixed. Here is a code fragment: snprintf(NULL, 0, "%*s1", INT_MAX, ""); This wants to return INT_MAX + 1U, but can't. snprintf() is so slow that you wish that INT_MAX were 32767 if you run this. The corresponding example for sprintf() needs a real buffer of size INT_MAX + 1U + 1 to avoid invoking undefined behaviour. Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Sat Jun 15 8:31: 6 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id D357437B4A5 for ; Sat, 15 Jun 2002 08:30:01 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g5FFU1M08830; Sat, 15 Jun 2002 08:30:01 -0700 (PDT) (envelope-from gnats) Received: from nwww.freebsd.org (www.FreeBSD.org [216.136.204.117]) by hub.freebsd.org (Postfix) with ESMTP id 4BEF437B646 for ; Sat, 15 Jun 2002 08:24:24 -0700 (PDT) Received: from www.freebsd.org (localhost [127.0.0.1]) by nwww.freebsd.org (8.12.2/8.12.2) with ESMTP id g5FFOOhG067690 for ; Sat, 15 Jun 2002 08:24:24 -0700 (PDT) (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.12.2/8.12.2/Submit) id g5FFOOaI067689; Sat, 15 Jun 2002 08:24:24 -0700 (PDT) Message-Id: <200206151524.g5FFOOaI067689@www.freebsd.org> Date: Sat, 15 Jun 2002 08:24:24 -0700 (PDT) From: Supat To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-1.0 Subject: standards/39333: adduser Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG >Number: 39333 >Category: standards >Synopsis: adduser >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-standards >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Jun 15 08:30:01 PDT 2002 >Closed-Date: >Last-Modified: >Originator: Supat >Release: 4.6mini >Organization: >Environment: >Description: When I use adduser, it asked to input the username for the first line. I typed some charector in and then it seem to be stored as a pattern for the next username. >How-To-Repeat: "adduser" >Fix: Can you let me know how to solve this problem? >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message From owner-freebsd-standards Sat Jun 15 12:47: 9 2002 Delivered-To: freebsd-standards@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id D5F0C37B412; Sat, 15 Jun 2002 12:47:07 -0700 (PDT) Received: (from mike@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g5FJl7S59566; Sat, 15 Jun 2002 12:47:07 -0700 (PDT) (envelope-from mike) Date: Sat, 15 Jun 2002 12:47:07 -0700 (PDT) From: Message-Id: <200206151947.g5FJl7S59566@freefall.freebsd.org> To: supat_a@hotmail.com, mike@FreeBSD.org, freebsd-standards@FreeBSD.org Subject: Re: standards/39333: adduser Sender: owner-freebsd-standards@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Synopsis: adduser State-Changed-From-To: open->closed State-Changed-By: mike State-Changed-When: Sat Jun 15 12:44:18 PDT 2002 State-Changed-Why: This isn't a valid PR. I would recommend you contact questions@FreeBSD.org if you're having trouble using adduser(8). http://www.freebsd.org/cgi/query-pr.cgi?pr=39333 To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message