CVS commit: src/bin/ps
Module Name:src Committed By: christos Date: Fri Jun 4 22:39:41 UTC 2021 Modified Files: src/bin/ps: ps.c Log Message: use parsenum like everywhere else in the code. To generate a diff of this commit: cvs rdiff -u -r1.95 -r1.96 src/bin/ps/ps.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.c diff -u src/bin/ps/ps.c:1.95 src/bin/ps/ps.c:1.96 --- src/bin/ps/ps.c:1.95 Fri Jun 4 04:17:53 2021 +++ src/bin/ps/ps.c Fri Jun 4 18:39:41 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ps.c,v 1.95 2021/06/04 08:17:53 wiz Exp $ */ +/* $NetBSD: ps.c,v 1.96 2021/06/04 22:39:41 christos Exp $ */ /* * Copyright (c) 2000-2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: ps.c,v 1.95 2021/06/04 08:17:53 wiz Exp $"); +__RCSID("$NetBSD: ps.c,v 1.96 2021/06/04 22:39:41 christos Exp $"); #endif #endif /* not lint */ @@ -257,20 +257,13 @@ main(int argc, char *argv[]) case 'G': if (*optarg != '\0') { struct group *gr; -char *ep; what = KERN_PROC_GID; gr = getgrnam(optarg); if (gr == NULL) { - errno = 0; - flag = strtoul(optarg, &ep, 10); - if (errno) - err(1, "%s", optarg); - if (*ep != '\0') - errx(1, "%s: illegal group", - optarg); - } else - flag = gr->gr_gid; + flag = parsenum(optarg, "group id"); +} else + flag = gr->gr_gid; } break; @@ -359,7 +352,7 @@ main(int argc, char *argv[]) what = KERN_PROC_UID; pw = getpwnam(optarg); if (pw == NULL) { - flag = parsenum(optarg, "user name"); + flag = parsenum(optarg, "user id"); } else flag = pw->pw_uid; }
CVS commit: src/bin/ps
Module Name:src Committed By: wiz Date: Fri Jun 4 08:17:53 UTC 2021 Modified Files: src/bin/ps: ps.c Log Message: Sort options in usage. To generate a diff of this commit: cvs rdiff -u -r1.94 -r1.95 src/bin/ps/ps.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.c diff -u src/bin/ps/ps.c:1.94 src/bin/ps/ps.c:1.95 --- src/bin/ps/ps.c:1.94 Fri Jun 4 06:28:42 2021 +++ src/bin/ps/ps.c Fri Jun 4 08:17:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ps.c,v 1.94 2021/06/04 06:28:42 cjep Exp $ */ +/* $NetBSD: ps.c,v 1.95 2021/06/04 08:17:53 wiz Exp $ */ /* * Copyright (c) 2000-2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: ps.c,v 1.94 2021/06/04 06:28:42 cjep Exp $"); +__RCSID("$NetBSD: ps.c,v 1.95 2021/06/04 08:17:53 wiz Exp $"); #endif #endif /* not lint */ @@ -965,8 +965,8 @@ usage(void) (void)fprintf(stderr, "usage:\t%s\n\t %s\n\t%s\n", - "ps [-AaCcdehjlmrSsTuvwx] [-k key] [-M core] [-N system] [-O fmt]", - "[-o fmt] [-p pid] [-t tty] [-U user] [-G group] [-W swap]", + "ps [-AaCcdehjlmrSsTuvwx] [-G group] [-k key] [-M core] [-N system]", + "[-O fmt] [-o fmt] [-p pid] [-t tty] [-U user] [-W swap]", "ps -L"); exit(1); /* NOTREACHED */
CVS commit: src/bin/ps
Module Name:src Committed By: wiz Date: Fri Jun 4 08:16:14 UTC 2021 Modified Files: src/bin/ps: ps.1 Log Message: Sort options in synopsis. To generate a diff of this commit: cvs rdiff -u -r1.111 -r1.112 src/bin/ps/ps.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.1 diff -u src/bin/ps/ps.1:1.111 src/bin/ps/ps.1:1.112 --- src/bin/ps/ps.1:1.111 Fri Jun 4 06:28:42 2021 +++ src/bin/ps/ps.1 Fri Jun 4 08:16:14 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: ps.1,v 1.111 2021/06/04 06:28:42 cjep Exp $ +.\" $NetBSD: ps.1,v 1.112 2021/06/04 08:16:14 wiz Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -38,6 +38,7 @@ .Sh SYNOPSIS .Nm .Op Fl AaCcdehjlmrSsTuvwx +.Op Fl G Ar group .Op Fl k Ar key .Op Fl M Ar core .Op Fl N Ar system @@ -46,7 +47,6 @@ .Op Fl p Ar pid .Op Fl t Ar tty .Op Fl U Ar user -.Op Fl G Ar group .Op Fl W Ar swap .Nm .Fl L @@ -719,6 +719,6 @@ Since cannot run faster than the system and is run as any other scheduled process, the information it displays can never be exact. .Pp -The -.Fl G +The +.Fl G option should ideally take a list instead of a single group.
CVS commit: src/bin/ps
Module Name:src Committed By: cjep Date: Fri Jun 4 06:28:42 UTC 2021 Modified Files: src/bin/ps: ps.1 ps.c Log Message: PR standards/11223 Add -G to take a single group argument heading towards POSIX.2 compliance. Patch from jperkin and reviewed by simonb. To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.111 src/bin/ps/ps.1 cvs rdiff -u -r1.93 -r1.94 src/bin/ps/ps.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.1 diff -u src/bin/ps/ps.1:1.110 src/bin/ps/ps.1:1.111 --- src/bin/ps/ps.1:1.110 Tue Aug 6 18:07:51 2019 +++ src/bin/ps/ps.1 Fri Jun 4 06:28:42 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: ps.1,v 1.110 2019/08/06 18:07:51 kamil Exp $ +.\" $NetBSD: ps.1,v 1.111 2021/06/04 06:28:42 cjep Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -46,6 +46,7 @@ .Op Fl p Ar pid .Op Fl t Ar tty .Op Fl U Ar user +.Op Fl G Ar group .Op Fl W Ar swap .Nm .Fl L @@ -110,6 +111,9 @@ relative to each other. Display the environment as well. The environment for other users' processes can only be displayed by the super-user. +.It Fl G Ar group +Display processes belonging to the users belonging to the specified group, +given either as a group name or a gid. .It Fl h Repeat the information header as often as necessary to guarantee one header per page of information. @@ -714,3 +718,7 @@ Since .Nm cannot run faster than the system and is run as any other scheduled process, the information it displays can never be exact. +.Pp +The +.Fl G +option should ideally take a list instead of a single group. Index: src/bin/ps/ps.c diff -u src/bin/ps/ps.c:1.93 src/bin/ps/ps.c:1.94 --- src/bin/ps/ps.c:1.93 Sun Sep 15 15:27:50 2019 +++ src/bin/ps/ps.c Fri Jun 4 06:28:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ps.c,v 1.93 2019/09/15 15:27:50 kamil Exp $ */ +/* $NetBSD: ps.c,v 1.94 2021/06/04 06:28:42 cjep Exp $ */ /* * Copyright (c) 2000-2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: ps.c,v 1.93 2019/09/15 15:27:50 kamil Exp $"); +__RCSID("$NetBSD: ps.c,v 1.94 2021/06/04 06:28:42 cjep Exp $"); #endif #endif /* not lint */ @@ -86,6 +86,7 @@ __RCSID("$NetBSD: ps.c,v 1.93 2019/09/15 #include #include #include +#include #include #include #include @@ -104,8 +105,8 @@ __RCSID("$NetBSD: ps.c,v 1.93 2019/09/15 * ARGOPTS must contain all option characters that take arguments * (except for 't'!) - it is used in kludge_oldps_options() */ -#define GETOPTSTR "aAcCdeghjk:LlM:mN:O:o:p:rSsTt:U:uvW:wx" -#define ARGOPTS "kMNOopUW" +#define GETOPTSTR "aAcCdegG:hjk:LlM:mN:O:o:p:rSsTt:U:uvW:wx" +#define ARGOPTS "GkMNOopUW" struct varlist displaylist = SIMPLEQ_HEAD_INITIALIZER(displaylist); struct varlist sortlist = SIMPLEQ_HEAD_INITIALIZER(sortlist); @@ -253,6 +254,26 @@ main(int argc, char *argv[]) break; case 'g': break; /* no-op */ + case 'G': + if (*optarg != '\0') { +struct group *gr; +char *ep; + +what = KERN_PROC_GID; +gr = getgrnam(optarg); +if (gr == NULL) { + errno = 0; + flag = strtoul(optarg, &ep, 10); + if (errno) + err(1, "%s", optarg); + if (*ep != '\0') + errx(1, "%s: illegal group", + optarg); + } else + flag = gr->gr_gid; + } + break; + case 'h': prtheader = ws.ws_row > 5 ? ws.ws_row : 22; break; @@ -945,7 +966,7 @@ usage(void) (void)fprintf(stderr, "usage:\t%s\n\t %s\n\t%s\n", "ps [-AaCcdehjlmrSsTuvwx] [-k key] [-M core] [-N system] [-O fmt]", - "[-o fmt] [-p pid] [-t tty] [-U user] [-W swap]", + "[-o fmt] [-p pid] [-t tty] [-U user] [-G group] [-W swap]", "ps -L"); exit(1); /* NOTREACHED */
CVS commit: src/bin/ps
Module Name:src Committed By: maya Date: Sat Apr 17 08:35:33 UTC 2021 Modified Files: src/bin/ps: print.c Log Message: Remove SCCS workaround. No binary change. To generate a diff of this commit: cvs rdiff -u -r1.134 -r1.135 src/bin/ps/print.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/print.c diff -u src/bin/ps/print.c:1.134 src/bin/ps/print.c:1.135 --- src/bin/ps/print.c:1.134 Tue Apr 6 13:35:52 2021 +++ src/bin/ps/print.c Sat Apr 17 08:35:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.134 2021/04/06 13:35:52 christos Exp $ */ +/* $NetBSD: print.c,v 1.135 2021/04/17 08:35:33 maya Exp $ */ /* * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: print.c,v 1.134 2021/04/06 13:35:52 christos Exp $"); +__RCSID("$NetBSD: print.c,v 1.135 2021/04/17 08:35:33 maya Exp $"); #endif #endif /* not lint */ @@ -800,11 +800,9 @@ started(struct pinfo *pi, VARENT *ve, en if (now == 0) (void)time(&now); if (now - k->p_ustart_sec < SECSPERDAY) - /* I *hate* SCCS... */ - safe_strftime(buf, sizeof(buf) - 1, "%l:%" "M%p", tp); + safe_strftime(buf, sizeof(buf) - 1, "%l:%M%p", tp); else if (now - k->p_ustart_sec < DAYSPERWEEK * SECSPERDAY) - /* I *hate* SCCS... */ - safe_strftime(buf, sizeof(buf) - 1, "%a%" "I%p", tp); + safe_strftime(buf, sizeof(buf) - 1, "%a%I%p", tp); else safe_strftime(buf, sizeof(buf) - 1, "%e%b%y", tp); /* %e and %l can start with a space. */
CVS commit: src/bin/ps
Module Name:src Committed By: christos Date: Tue Apr 6 13:35:52 UTC 2021 Modified Files: src/bin/ps: print.c Log Message: - dedup code - add a safe_strftime() to handle error cases To generate a diff of this commit: cvs rdiff -u -r1.133 -r1.134 src/bin/ps/print.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/print.c diff -u src/bin/ps/print.c:1.133 src/bin/ps/print.c:1.134 --- src/bin/ps/print.c:1.133 Tue Apr 6 01:13:24 2021 +++ src/bin/ps/print.c Tue Apr 6 09:35:52 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.133 2021/04/06 05:13:24 simonb Exp $ */ +/* $NetBSD: print.c,v 1.134 2021/04/06 13:35:52 christos Exp $ */ /* * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: print.c,v 1.133 2021/04/06 05:13:24 simonb Exp $"); +__RCSID("$NetBSD: print.c,v 1.134 2021/04/06 13:35:52 christos Exp $"); #endif #endif /* not lint */ @@ -109,6 +109,14 @@ static time_t now; #define LSDEAD 6 #endif +static void __attribute__((__format__(__strftime__, 3, 0))) +safe_strftime(char *buf, size_t bufsiz, const char *fmt, +const struct tm *tp) +{ + if (tp == NULL || strftime(buf, bufsiz, fmt, tp) == 0) + strlcpy(buf, "-", sizeof(buf)); +} + static int iwidth(u_int64_t v) { @@ -793,12 +801,12 @@ started(struct pinfo *pi, VARENT *ve, en (void)time(&now); if (now - k->p_ustart_sec < SECSPERDAY) /* I *hate* SCCS... */ - (void)strftime(buf, sizeof(buf) - 1, "%l:%" "M%p", tp); + safe_strftime(buf, sizeof(buf) - 1, "%l:%" "M%p", tp); else if (now - k->p_ustart_sec < DAYSPERWEEK * SECSPERDAY) /* I *hate* SCCS... */ - (void)strftime(buf, sizeof(buf) - 1, "%a%" "I%p", tp); + safe_strftime(buf, sizeof(buf) - 1, "%a%" "I%p", tp); else - (void)strftime(buf, sizeof(buf) - 1, "%e%b%y", tp); + safe_strftime(buf, sizeof(buf) - 1, "%e%b%y", tp); /* %e and %l can start with a space. */ cp = buf; if (*cp == ' ') @@ -829,20 +837,17 @@ lstarted(struct pinfo *pi, VARENT *ve, e * XXX: The hardcoded "STARTED" string. Better or * worse than a "<= 7" or some other arbitary number? */ - if (v->width <= (int)strlen("STARTED")) { - (void)strftime(buf, sizeof(buf) -1, "%c", - localtime(&startt)); - strprintorsetwidth(v, buf, mode); + if (v->width > (int)sizeof("STARTED") - 1) { + return; } } else { if (!k->p_uvalid) { (void)printf("%*s", v->width, "-"); - } else { - (void)strftime(buf, sizeof(buf) -1, "%c", - localtime(&startt)); - strprintorsetwidth(v, buf, mode); + return; } } + safe_strftime(buf, sizeof(buf) - 1, "%c", localtime(&startt)); + strprintorsetwidth(v, buf, mode); } void
CVS commit: src/bin/ps
Module Name:src Committed By: simonb Date: Tue Apr 6 05:13:24 UTC 2021 Modified Files: src/bin/ps: print.c Log Message: Fix the column width calculation for the lstart column if an empty column header is specified. Fixes bug pointed out by Ted Spradley in https://mail-index.netbsd.org/netbsd-users/2021/04/05/msg026808.html . To generate a diff of this commit: cvs rdiff -u -r1.132 -r1.133 src/bin/ps/print.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/print.c diff -u src/bin/ps/print.c:1.132 src/bin/ps/print.c:1.133 --- src/bin/ps/print.c:1.132 Wed Jun 19 21:25:50 2019 +++ src/bin/ps/print.c Tue Apr 6 05:13:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.132 2019/06/19 21:25:50 kamil Exp $ */ +/* $NetBSD: print.c,v 1.133 2021/04/06 05:13:24 simonb Exp $ */ /* * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: print.c,v 1.132 2019/06/19 21:25:50 kamil Exp $"); +__RCSID("$NetBSD: print.c,v 1.133 2021/04/06 05:13:24 simonb Exp $"); #endif #endif /* not lint */ @@ -815,22 +815,33 @@ lstarted(struct pinfo *pi, VARENT *ve, e char buf[100]; v = ve->var; - if (!k->p_uvalid) { + startt = k->p_ustart_sec; + + if (mode == WIDTHMODE) { /* - * Minimum width is less than header - we don't - * need to check it every time. + * We only need to set the width once, as we assume + * that all times are the same length. We do need to + * check against the header length as well, as "no + * header" mode for this variable will set the field + * width to the length of the header anyway (ref: the + * P1003.1-2004 comment in findvar()). + * + * XXX: The hardcoded "STARTED" string. Better or + * worse than a "<= 7" or some other arbitary number? */ - if (mode == PRINTMODE) + if (v->width <= (int)strlen("STARTED")) { + (void)strftime(buf, sizeof(buf) -1, "%c", + localtime(&startt)); + strprintorsetwidth(v, buf, mode); + } + } else { + if (!k->p_uvalid) { (void)printf("%*s", v->width, "-"); - return; - } - startt = k->p_ustart_sec; - - /* assume all times are the same length */ - if (mode != WIDTHMODE || v->width == 0) { - (void)strftime(buf, sizeof(buf) -1, "%c", - localtime(&startt)); - strprintorsetwidth(v, buf, mode); + } else { + (void)strftime(buf, sizeof(buf) -1, "%c", + localtime(&startt)); + strprintorsetwidth(v, buf, mode); + } } }
CVS commit: src/bin/ps
Module Name:src Committed By: simonb Date: Tue Apr 6 04:49:41 UTC 2021 Modified Files: src/bin/ps: Makefile Log Message: We only need -Wno-format-y2k for print.c . To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/bin/ps/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/Makefile diff -u src/bin/ps/Makefile:1.29 src/bin/ps/Makefile:1.30 --- src/bin/ps/Makefile:1.29 Sun Aug 14 10:53:17 2011 +++ src/bin/ps/Makefile Tue Apr 6 04:49:41 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.29 2011/08/14 10:53:17 christos Exp $ +# $NetBSD: Makefile,v 1.30 2021/04/06 04:49:41 simonb Exp $ # @(#)Makefile 8.1 (Berkeley) 6/2/93 PROG= ps @@ -6,7 +6,6 @@ SRCS= fmt.c keyword.c nlist.c print.c p DPADD= ${LIBM} ${LIBKVM} LDADD= -lm -lkvm -CWARNFLAGS+= -Wno-format-y2k -COPTS.print.c = -Wno-format-nonliteral +COPTS.print.c = -Wno-format-nonliteral -Wno-format-y2k .include
CVS commit: src/bin/ps
Module Name:src Committed By: simonb Date: Wed Aug 26 10:54:13 UTC 2020 Modified Files: src/bin/ps: nlist.c Log Message: Don't rely on the USPACE kernel define as a fallback if the vm.uspace sysctl fails. We've got bigger problems if the sysctl fail anyway. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/bin/ps/nlist.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/nlist.c diff -u src/bin/ps/nlist.c:1.27 src/bin/ps/nlist.c:1.28 --- src/bin/ps/nlist.c:1.27 Mon Nov 28 08:19:23 2016 +++ src/bin/ps/nlist.c Wed Aug 26 10:54:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nlist.c,v 1.27 2016/11/28 08:19:23 rin Exp $ */ +/* $NetBSD: nlist.c,v 1.28 2020/08/26 10:54:12 simonb Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)nlist.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: nlist.c,v 1.27 2016/11/28 08:19:23 rin Exp $"); +__RCSID("$NetBSD: nlist.c,v 1.28 2020/08/26 10:54:12 simonb Exp $"); #endif #endif /* not lint */ @@ -113,9 +113,7 @@ int uspace;/* kernel USPACE value */ #ifndef MAXSLP #define MAXSLP 20 #endif -#ifndef USPACE -#define USPACE (getpagesize()) -#endif +#define DEF_USPACE (getpagesize()) #define kread(x, v) \ kvm_read(kd, psnl[x].n_value, (char *)&v, sizeof v) != sizeof(v) @@ -177,7 +175,7 @@ donlist_sysctl(void) mib[1] = KERN_FSCALE; size = sizeof(fscale); if (sysctl(mib, 2, &fscale, &size, NULL, 0)) { - warn("fscale"); + warn("sysctl kern.fscale"); eval = 1; fscale = FSCALE; } @@ -186,7 +184,7 @@ donlist_sysctl(void) mib[1] = HW_PHYSMEM64; size = sizeof(memsize); if (sysctl(mib, 2, &memsize, &size, NULL, 0)) { - warn("avail_start"); + warn("sysctl hw.avail_start"); eval = 1; mempages = MEMPAGES; } else @@ -196,7 +194,7 @@ donlist_sysctl(void) mib[1] = KERN_CCPU; size = sizeof(xccpu); if (sysctl(mib, 2, &xccpu, &size, NULL, 0)) { - warn("ccpu"); + warn("sysctl kern.ccpu"); eval = 1; log_ccpu = LOG_CCPU; } else @@ -206,7 +204,7 @@ donlist_sysctl(void) mib[1] = VM_MAXSLP; size = sizeof(maxslp); if (sysctl(mib, 2, &maxslp, &size, NULL, 0)) { - warn("maxslp"); + warn("sysctl vm.maxslp"); eval = 1; maxslp = MAXSLP; } @@ -215,9 +213,9 @@ donlist_sysctl(void) mib[1] = VM_USPACE; size = sizeof(uspace); if (sysctl(mib, 2, &uspace, &size, NULL, 0)) { - warn("uspace"); + warn("sysctl vm.uspace"); eval = 1; - uspace = USPACE; + uspace = DEF_USPACE; } }
CVS commit: src/bin/ps
Module Name:src Committed By: maxv Date: Wed Sep 19 15:20:39 UTC 2018 Modified Files: src/bin/ps: print.c Log Message: Don't display l_wchan, either there is something in l_wmesg and we display it, or there's nothing and we print "-". To generate a diff of this commit: cvs rdiff -u -r1.129 -r1.130 src/bin/ps/print.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/print.c diff -u src/bin/ps/print.c:1.129 src/bin/ps/print.c:1.130 --- src/bin/ps/print.c:1.129 Wed Apr 11 18:52:05 2018 +++ src/bin/ps/print.c Wed Sep 19 15:20:39 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.129 2018/04/11 18:52:05 christos Exp $ */ +/* $NetBSD: print.c,v 1.130 2018/09/19 15:20:39 maxv Exp $ */ /* * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: print.c,v 1.129 2018/04/11 18:52:05 christos Exp $"); +__RCSID("$NetBSD: print.c,v 1.130 2018/09/19 15:20:39 maxv Exp $"); #endif #endif /* not lint */ @@ -927,22 +927,11 @@ wchan(struct pinfo *pi, VARENT *ve, enum { struct kinfo_lwp *l = pi->li; VAR *v; - char *buf; v = ve->var; - if (l->l_wchan) { - if (l->l_wmesg[0]) { - strprintorsetwidth(v, l->l_wmesg, mode); - v->width = min(v->width, KI_WMESGLEN); - } else { - (void)asprintf(&buf, "%-*" PRIx64, v->width, - l->l_wchan); - if (buf == NULL) -err(EXIT_FAILURE, "%s", ""); - strprintorsetwidth(v, buf, mode); - v->width = min(v->width, KI_WMESGLEN); - free(buf); - } + if (l->l_wmesg[0]) { + strprintorsetwidth(v, l->l_wmesg, mode); + v->width = min(v->width, KI_WMESGLEN); } else { if (mode == PRINTMODE) (void)printf("%-*s", v->width, "-");
CVS commit: src/bin/ps
Module Name:src Committed By: christos Date: Wed Apr 11 18:52:29 UTC 2018 Modified Files: src/bin/ps: ps.c Log Message: kvm_geterr() already contains errno, use errx. To generate a diff of this commit: cvs rdiff -u -r1.90 -r1.91 src/bin/ps/ps.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.c diff -u src/bin/ps/ps.c:1.90 src/bin/ps/ps.c:1.91 --- src/bin/ps/ps.c:1.90 Wed Apr 11 14:52:05 2018 +++ src/bin/ps/ps.c Wed Apr 11 14:52:29 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ps.c,v 1.90 2018/04/11 18:52:05 christos Exp $ */ +/* $NetBSD: ps.c,v 1.91 2018/04/11 18:52:29 christos Exp $ */ /* * Copyright (c) 2000-2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: ps.c,v 1.90 2018/04/11 18:52:05 christos Exp $"); +__RCSID("$NetBSD: ps.c,v 1.91 2018/04/11 18:52:29 christos Exp $"); #endif #endif /* not lint */ @@ -425,7 +425,7 @@ main(int argc, char *argv[]) * select procs */ if (!(kinfo = getkinfo_kvm(kd, what, flag, &nentries))) - err(EXIT_FAILURE, "%s", kvm_geterr(kd)); + errx(EXIT_FAILURE, "%s", kvm_geterr(kd)); if (nentries == 0) { printheader(); return 1;
CVS commit: src/bin/ps
Module Name:src Committed By: christos Date: Wed Apr 11 18:52:05 UTC 2018 Modified Files: src/bin/ps: keyword.c print.c ps.c Log Message: use EXIT_FAILURE instead of 1 To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/bin/ps/keyword.c cvs rdiff -u -r1.128 -r1.129 src/bin/ps/print.c cvs rdiff -u -r1.89 -r1.90 src/bin/ps/ps.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/keyword.c diff -u src/bin/ps/keyword.c:1.55 src/bin/ps/keyword.c:1.56 --- src/bin/ps/keyword.c:1.55 Sat Dec 9 09:56:54 2017 +++ src/bin/ps/keyword.c Wed Apr 11 14:52:05 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: keyword.c,v 1.55 2017/12/09 14:56:54 kamil Exp $ */ +/* $NetBSD: keyword.c,v 1.56 2018/04/11 18:52:05 christos Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)keyword.c 8.5 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: keyword.c,v 1.55 2017/12/09 14:56:54 kamil Exp $"); +__RCSID("$NetBSD: keyword.c,v 1.56 2018/04/11 18:52:05 christos Exp $"); #endif #endif /* not lint */ @@ -308,7 +308,7 @@ parsevarlist(const char *pp, struct varl if ((v = findvar(cp)) == NULL) continue; if ((vent = malloc(sizeof(struct varent))) == NULL) - err(1, NULL); + err(EXIT_FAILURE, NULL); vent->var = v; if (pos && *pos) SIMPLEQ_INSERT_AFTER(listptr, *pos, vent, next); @@ -320,7 +320,7 @@ parsevarlist(const char *pp, struct varl } free(sp); if (SIMPLEQ_EMPTY(listptr)) - errx(1, "no valid keywords"); + errx(EXIT_FAILURE, "no valid keywords"); } void @@ -389,9 +389,9 @@ findvar(const char *p) char *newheader; if ((newvar = malloc(sizeof(struct var))) == NULL) - err(1, NULL); + err(EXIT_FAILURE, NULL); if ((newheader = strdup(hp)) == NULL) - err(1, NULL); + err(EXIT_FAILURE, NULL); memcpy(newvar, v, sizeof(struct var)); newvar->header = newheader; Index: src/bin/ps/print.c diff -u src/bin/ps/print.c:1.128 src/bin/ps/print.c:1.129 --- src/bin/ps/print.c:1.128 Sat Dec 9 09:56:54 2017 +++ src/bin/ps/print.c Wed Apr 11 14:52:05 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.128 2017/12/09 14:56:54 kamil Exp $ */ +/* $NetBSD: print.c,v 1.129 2018/04/11 18:52:05 christos Exp $ */ /* * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: print.c,v 1.128 2017/12/09 14:56:54 kamil Exp $"); +__RCSID("$NetBSD: print.c,v 1.129 2018/04/11 18:52:05 christos Exp $"); #endif #endif /* not lint */ @@ -938,7 +938,7 @@ wchan(struct pinfo *pi, VARENT *ve, enum (void)asprintf(&buf, "%-*" PRIx64, v->width, l->l_wchan); if (buf == NULL) -err(1, "%s", ""); +err(EXIT_FAILURE, "%s", ""); strprintorsetwidth(v, buf, mode); v->width = min(v->width, KI_WMESGLEN); free(buf); @@ -1333,7 +1333,7 @@ printval(void *bp, VAR *v, enum mode mod (void)printf(ofmt, width, CHK_INF127(GET(u_int64_t))); return; default: - errx(1, "unknown type %d", v->type); + errx(EXIT_FAILURE, "unknown type %d", v->type); } #undef GET #undef CHK_INF127 Index: src/bin/ps/ps.c diff -u src/bin/ps/ps.c:1.89 src/bin/ps/ps.c:1.90 --- src/bin/ps/ps.c:1.89 Fri Jan 12 18:01:14 2018 +++ src/bin/ps/ps.c Wed Apr 11 14:52:05 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ps.c,v 1.89 2018/01/12 23:01:14 kamil Exp $ */ +/* $NetBSD: ps.c,v 1.90 2018/04/11 18:52:05 christos Exp $ */ /* * Copyright (c) 2000-2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: ps.c,v 1.89 2018/01/12 23:01:14 kamil Exp $"); +__RCSID("$NetBSD: ps.c,v 1.90 2018/04/11 18:52:05 christos Exp $"); #endif #endif /* not lint */ @@ -189,10 +189,10 @@ ttyname2dev(const char *ttname, int *xfl return makedev(pts, ptsminor); } errno = serrno; - err(1, "%s", ttypath); + err(EXIT_FAILURE, "%s", ttypath); } if (!S_ISCHR(sb.st_mode)) - errx(1, "%s: not a terminal", ttypath); + errx(EXIT_FAILURE, "%s: not a terminal", ttypath); return sb.st_rdev; } @@ -325,7 +325,7 @@ main(int argc, char *argv[]) break; case 'T': if ((ttname = ttyname(STDIN_FILENO)) == NULL) -errx(1, "stdin: not a terminal"); +errx(EXIT_FAILURE, "stdin: not a terminal"); flag = ttyname2dev(ttname, &xflg, &what); break; case 't': @@ -394,7 +394,7 @@ main(int argc, char *argv[]) kd = kvm_openfiles(nlistf, memf, swapf, O_RDONLY, errbuf); if (kd == NULL) - errx(1, "%s", errbuf); + errx(EXIT_FAILURE, "%s", errbuf); if (!fmt) parsefmt(default_fmt); @@ -425,7 +425,7 @@ main(int argc, char *argv[]) * select procs */ if (!(kinfo = getkinfo_kvm(kd, what, flag, &nentries))) - err(1, "%s", kvm_geterr(kd)); + err(EXIT_FAILURE, "%s", kvm_geterr(kd)); if (nentries == 0) { printheader
CVS commit: src/bin/ps
Module Name:src Committed By: kamil Date: Fri Jan 12 23:01:14 UTC 2018 Modified Files: src/bin/ps: ps.c Log Message: Fix an unitialized memory read bug in ps(1) rawcpu of type int, is declared inside main(){} and it can be passed as uninitialized to setpinfo(). The setpinfo() function has a switch checking the value of rawcpu: if (!rawcpu) pi[i].pcpu /= 1.0 - exp(ki[i].p_swtime * log_ccpu); rawcpu is set to 1 with the command line argument "-C". -C Change the way the CPU percentage is calculated by using a "raw" CPU calculation that ignores "resident" time (this normally has no effect). Bug reproducible with an invocation: "ps u". It hides with "ps uC". Initialize rawcpu by default to 0, before the getopt(3) machinery. Detected with MSan running on NetBSD/amd64. Sponsored by To generate a diff of this commit: cvs rdiff -u -r1.88 -r1.89 src/bin/ps/ps.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.c diff -u src/bin/ps/ps.c:1.88 src/bin/ps/ps.c:1.89 --- src/bin/ps/ps.c:1.88 Mon Dec 26 20:52:39 2016 +++ src/bin/ps/ps.c Fri Jan 12 23:01:14 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: ps.c,v 1.88 2016/12/26 20:52:39 rin Exp $ */ +/* $NetBSD: ps.c,v 1.89 2018/01/12 23:01:14 kamil Exp $ */ /* * Copyright (c) 2000-2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: ps.c,v 1.88 2016/12/26 20:52:39 rin Exp $"); +__RCSID("$NetBSD: ps.c,v 1.89 2018/01/12 23:01:14 kamil Exp $"); #endif #endif /* not lint */ @@ -224,7 +224,7 @@ main(int argc, char *argv[]) if (argc > 1) argv[1] = kludge_oldps_options(argv[1]); - descendancy = fmt = prtheader = wflag = xflg = showlwps = 0; + descendancy = fmt = prtheader = wflag = xflg = rawcpu = showlwps = 0; what = KERN_PROC_UID; flag = myuid = getuid(); memf = nlistf = swapf = NULL;
CVS commit: src/bin/ps
Module Name:src Committed By: kamil Date: Sat Dec 9 14:56:54 UTC 2017 Modified Files: src/bin/ps: extern.h keyword.c print.c Log Message: ps: Rename local routine name from uname to usrname This removes symbol name routine clash with libc's uname(3). This allows to build ps(1) against LLVM Sanitizers. Sponsored by To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/bin/ps/extern.h cvs rdiff -u -r1.54 -r1.55 src/bin/ps/keyword.c cvs rdiff -u -r1.127 -r1.128 src/bin/ps/print.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/extern.h diff -u src/bin/ps/extern.h:1.38 src/bin/ps/extern.h:1.39 --- src/bin/ps/extern.h:1.38 Fri Dec 2 21:59:03 2016 +++ src/bin/ps/extern.h Sat Dec 9 14:56:54 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.38 2016/12/02 21:59:03 christos Exp $ */ +/* $NetBSD: extern.h,v 1.39 2017/12/09 14:56:54 kamil Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -93,7 +93,7 @@ void tdev(struct pinfo *, VARENT *, enu void tname(struct pinfo *, VARENT *, enum mode); void tsize(struct pinfo *, VARENT *, enum mode); void ucomm(struct pinfo *, VARENT *, enum mode); -void uname(struct pinfo *, VARENT *, enum mode); +void usrname(struct pinfo *, VARENT *, enum mode); void uvar(struct pinfo *, VARENT *, enum mode); void vsize(struct pinfo *, VARENT *, enum mode); void wchan(struct pinfo *, VARENT *, enum mode); Index: src/bin/ps/keyword.c diff -u src/bin/ps/keyword.c:1.54 src/bin/ps/keyword.c:1.55 --- src/bin/ps/keyword.c:1.54 Wed Jan 15 08:07:53 2014 +++ src/bin/ps/keyword.c Sat Dec 9 14:56:54 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: keyword.c,v 1.54 2014/01/15 08:07:53 mlelstv Exp $ */ +/* $NetBSD: keyword.c,v 1.55 2017/12/09 14:56:54 kamil Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)keyword.c 8.5 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: keyword.c,v 1.54 2014/01/15 08:07:53 mlelstv Exp $"); +__RCSID("$NetBSD: keyword.c,v 1.55 2017/12/09 14:56:54 kamil Exp $"); #endif #endif /* not lint */ @@ -126,7 +126,7 @@ VAR var[] = { VAR4("emul", "EMUL", LJUST, emul), VAR6("etime", "ELAPSED", 0, elapsed, POFF(p_ustart_sec), TIMEVAL), UID("euid", "EUID", p_uid), - VAR4("euser", "EUSER", LJUST, uname), + VAR4("euser", "EUSER", LJUST, usrname), PVAR("f", "F", 0, p_flag, INT, "x"), VAR3("flags", "f", ALIAS), GID("gid", "GID", p_gid), @@ -213,7 +213,7 @@ VAR var[] = { VAR4("ucomm", "UCOMM", LJUST, ucomm), UID("uid", "UID", p_uid), LVAR("upr", "UPR", 0, l_usrpri, UCHAR, "u"), - VAR4("user", "USER", LJUST, uname), + VAR4("user", "USER", LJUST, usrname), VAR3("usrpri", "upr", ALIAS), VAR6("utime", "UTIME", 0, putimeval, POFF(p_uutime_sec), TIMEVAL), VAR3("vsize", "vsz", ALIAS), Index: src/bin/ps/print.c diff -u src/bin/ps/print.c:1.127 src/bin/ps/print.c:1.128 --- src/bin/ps/print.c:1.127 Mon Dec 12 20:35:36 2016 +++ src/bin/ps/print.c Sat Dec 9 14:56:54 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.127 2016/12/12 20:35:36 christos Exp $ */ +/* $NetBSD: print.c,v 1.128 2017/12/09 14:56:54 kamil Exp $ */ /* * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: print.c,v 1.127 2016/12/12 20:35:36 christos Exp $"); +__RCSID("$NetBSD: print.c,v 1.128 2017/12/09 14:56:54 kamil Exp $"); #endif #endif /* not lint */ @@ -629,7 +629,7 @@ pri(struct pinfo *pi, VARENT *ve, enum m } void -uname(struct pinfo *pi, VARENT *ve, enum mode mode) +usrname(struct pinfo *pi, VARENT *ve, enum mode mode) { struct kinfo_proc2 *k = pi->ki; VAR *v;
CVS commit: src/bin/ps
Module Name:src Committed By: wiz Date: Mon Aug 28 05:57:37 UTC 2017 Modified Files: src/bin/ps: ps.1 Log Message: Bump date for previous. Remove/replace bogus Tn uses. To generate a diff of this commit: cvs rdiff -u -r1.108 -r1.109 src/bin/ps/ps.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.1 diff -u src/bin/ps/ps.1:1.108 src/bin/ps/ps.1:1.109 --- src/bin/ps/ps.1:1.108 Mon Aug 28 00:46:06 2017 +++ src/bin/ps/ps.1 Mon Aug 28 05:57:37 2017 @@ -1,4 +1,4 @@ -.\" $NetBSD: ps.1,v 1.108 2017/08/28 00:46:06 kamil Exp $ +.\" $NetBSD: ps.1,v 1.109 2017/08/28 05:57:37 wiz Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)ps.1 8.3 (Berkeley) 4/18/94 .\" -.Dd December 2, 2016 +.Dd August 28, 2017 .Dt PS 1 .Os .Sh NAME @@ -56,8 +56,7 @@ running processes. By default, the display includes only processes that have controlling terminals and are owned by your uid. The default sort order of controlling terminal and -(among processes with the same controlling terminal) process -.Tn ID +(among processes with the same controlling terminal) process ID may be changed using the .Fl k , Fl m , or @@ -71,8 +70,7 @@ is selected based on a set of keywords ( and .Fl o options). -The default output format includes, for each process, the process' -.Tn ID , +The default output format includes, for each process, the process' ID, controlling terminal, CPU time (including both user and system time), state, and associated command. .Pp @@ -204,8 +202,7 @@ If all the keywords to be displayed have and all the customised headers are entirely empty, then the header line is not printed at all. .It Fl p Ar pid -Display information associated with the specified process -.Tn ID . +Display information associated with the specified process ID. .It Fl r Sort by current CPU usage. This is equivalent to @@ -282,9 +279,7 @@ Some of these keywords are further speci The CPU utilization of the process; this is a decaying average over up to a minute of previous (real) time. Since the time base over which this is computed varies (since processes may -be very young) it is possible for the sum of all -.Tn %CPU -fields to exceed 100%. +be very young) it is possible for the sum of all %CPU fields to exceed 100%. .It Ar %mem The percentage of real memory used by this process. .It Ar flags @@ -342,7 +337,7 @@ Otherwise, the start time is displayed u format. .It Ar state The state is given by a sequence of letters, for example, -.Dq Tn RNs . +.Dq RNs . The first letter indicates the run state of the process: .Pp .Bl -tag -width indent -compact @@ -378,9 +373,7 @@ The process is in the foreground process .It - The LWP is detached (can't be waited for). .It < -The process has raised -.Tn CPU -scheduling priority. +The process has raised CPU scheduling priority. .It a The process is using scheduler activations (deprecated). .It E @@ -390,9 +383,7 @@ The process is a kernel thread or system .It l The process has multiple LWPs. .It N -The process is niced (has reduced -.Tn CPU -scheduling priority) (see +The process is niced (has reduced CPU scheduling priority) (see .Xr setpriority 2 ) . .It s The process is a session leader. @@ -533,7 +524,7 @@ tracing flags tracing vnode .It Ar laddr kernel virtual address of the -.Tn "struct lwp" +.Ft "struct lwp" belonging to the LWP. .It Ar lid ID of the LWP @@ -579,25 +570,22 @@ total blocks written (alias resource usage pointer (valid only for zombie) .It Ar paddr kernel virtual address of the -.Tn "struct proc" +.Ft "struct proc" belonging to the process. .It Ar pagein pageins (same as majflt) .It Ar pgid process group number .It Ar pid -process -.Tn ID +process ID .It Ar ppid -parent process -.Tn ID +parent process ID .It Ar pri scheduling priority .It Ar re core residency time (in seconds; 127 = infinity) .It Ar rgid -real group -.Tn ID +real group ID .It Ar rlink reverse link on run queue, or 0 .It Ar rlwp @@ -608,15 +596,13 @@ resident set size resident set size + (text size / text use count) (alias .Ar rssize ) .It Ar ruid -real user -.Tn ID +real user ID .It Ar ruser user name (from ruid) .It Ar sess session pointer .It Ar sid -session -.Tn ID +session ID .It Ar sig pending signals (alias .Ar pending ) @@ -652,8 +638,7 @@ control terminal device number accumulated CPU time, user + system (alias .Ar cputime ) .It Ar tpgid -control terminal process group -.Tn ID +control terminal process group ID .It Ar tsess control terminal session pointer .It Ar tsiz @@ -664,13 +649,12 @@ control terminal name (two letter abbrev full name of control terminal .It Ar uaddr kernel virtual address of the -.Tn "struct user" +.Ft "struct user" belonging to the LWP. .It Ar ucomm name to be used for accounting
CVS commit: src/bin/ps
Module Name:src Committed By: rin Date: Mon Dec 26 20:52:39 UTC 2016 Modified Files: src/bin/ps: ps.c Log Message: simplify logic; there must be no CPU usage when p_swtime is zero To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/bin/ps/ps.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.c diff -u src/bin/ps/ps.c:1.87 src/bin/ps/ps.c:1.88 --- src/bin/ps/ps.c:1.87 Fri Dec 2 21:59:03 2016 +++ src/bin/ps/ps.c Mon Dec 26 20:52:39 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ps.c,v 1.87 2016/12/02 21:59:03 christos Exp $ */ +/* $NetBSD: ps.c,v 1.88 2016/12/26 20:52:39 rin Exp $ */ /* * Copyright (c) 2000-2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: ps.c,v 1.87 2016/12/02 21:59:03 christos Exp $"); +__RCSID("$NetBSD: ps.c,v 1.88 2016/12/26 20:52:39 rin Exp $"); #endif #endif /* not lint */ @@ -611,8 +611,7 @@ setpinfo(struct kinfo_proc2 *ki, int nen pi[i].ki = &ki[i]; if (!calc_pcpu) continue; - if (ki[i].p_realstat == SZOMB || - (!rawcpu && ki[i].p_swtime == 0)) { + if (ki[i].p_swtime == 0 || ki[i].p_realstat == SZOMB) { pi[i].pcpu = 0.0; continue; }
CVS commit: src/bin/ps
Module Name:src Committed By: christos Date: Mon Dec 12 20:35:36 UTC 2016 Modified Files: src/bin/ps: print.c Log Message: Handle functions that use the offset from either kinfo_proc2/kinfo_lwp properly. To generate a diff of this commit: cvs rdiff -u -r1.126 -r1.127 src/bin/ps/print.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/print.c diff -u src/bin/ps/print.c:1.126 src/bin/ps/print.c:1.127 --- src/bin/ps/print.c:1.126 Fri Dec 2 16:59:03 2016 +++ src/bin/ps/print.c Mon Dec 12 15:35:36 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.126 2016/12/02 21:59:03 christos Exp $ */ +/* $NetBSD: print.c,v 1.127 2016/12/12 20:35:36 christos Exp $ */ /* * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: print.c,v 1.126 2016/12/02 21:59:03 christos Exp $"); +__RCSID("$NetBSD: print.c,v 1.127 2016/12/12 20:35:36 christos Exp $"); #endif #endif /* not lint */ @@ -1342,17 +1342,16 @@ printval(void *bp, VAR *v, enum mode mod void pvar(struct pinfo *pi, VARENT *ve, enum mode mode) { - struct kinfo_proc2 *ki = pi->ki; - VAR *v; + VAR *v = ve->var; + char *b = (v->flag & LWP) ? (char *)pi->li : (char *)pi->ki; - v = ve->var; - if (v->flag & UAREA && !ki->p_uvalid) { + if ((v->flag & UAREA) && !pi->ki->p_uvalid) { if (mode == PRINTMODE) (void)printf("%*s", v->width, "-"); return; } - (void)printval((char *)ki + v->off, v, mode); + (void)printval(b + v->off, v, mode); } void @@ -1360,8 +1359,9 @@ putimeval(struct pinfo *pi, VARENT *ve, { VAR *v = ve->var; struct kinfo_proc2 *k = pi->ki; - ulong secs = *(uint32_t *)((char *)k + v->off); - ulong usec = *(uint32_t *)((char *)k + v->off + sizeof (uint32_t)); + char *b = (v->flag & LWP) ? (char *)pi->li : (char *)pi->ki; + ulong secs = *(uint32_t *)(b + v->off); + ulong usec = *(uint32_t *)(b + v->off + sizeof (uint32_t)); int fmtlen; if (!k->p_uvalid) {
CVS commit: src/bin/ps
Module Name:src Committed By: christos Date: Fri Dec 2 21:59:03 UTC 2016 Modified Files: src/bin/ps: extern.h print.c ps.1 ps.c ps.h Log Message: provide a tree like display with -d, from FreeBSD To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/bin/ps/extern.h cvs rdiff -u -r1.125 -r1.126 src/bin/ps/print.c cvs rdiff -u -r1.105 -r1.106 src/bin/ps/ps.1 cvs rdiff -u -r1.86 -r1.87 src/bin/ps/ps.c cvs rdiff -u -r1.28 -r1.29 src/bin/ps/ps.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/extern.h diff -u src/bin/ps/extern.h:1.37 src/bin/ps/extern.h:1.38 --- src/bin/ps/extern.h:1.37 Mon Nov 28 03:21:10 2016 +++ src/bin/ps/extern.h Fri Dec 2 16:59:03 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.37 2016/11/28 08:21:10 rin Exp $ */ +/* $NetBSD: extern.h,v 1.38 2016/12/02 21:59:03 christos Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -46,54 +46,54 @@ extern VAR var[]; extern VARLIST displaylist; extern VARLIST sortlist; -void command(void *, VARENT *, enum mode); -void cpuid(void *, VARENT *, enum mode); -void cputime(void *, VARENT *, enum mode); +void command(struct pinfo *, VARENT *, enum mode); +void cpuid(struct pinfo *, VARENT *, enum mode); +void cputime(struct pinfo *, VARENT *, enum mode); void donlist(void); void donlist_sysctl(void); void fmt_puts(char *, int *); void fmt_putc(int, int *); -void elapsed(void *, VARENT *, enum mode); +void elapsed(struct pinfo *, VARENT *, enum mode); double getpcpu(const struct kinfo_proc2 *); double getpmem(const struct kinfo_proc2 *); -void gname(void *, VARENT *, enum mode); -void groups(void *, VARENT *, enum mode); -void groupnames(void *, VARENT *, enum mode); -void lcputime(void *, VARENT *, enum mode); -void logname(void *, VARENT *, enum mode); -void longtname(void *, VARENT *, enum mode); -void lname(void *, VARENT *, enum mode); -void lstarted(void *, VARENT *, enum mode); -void lstate(void *, VARENT *, enum mode); -void maxrss(void *, VARENT *, enum mode); +void gname(struct pinfo *, VARENT *, enum mode); +void groups(struct pinfo *, VARENT *, enum mode); +void groupnames(struct pinfo *, VARENT *, enum mode); +void lcputime(struct pinfo *, VARENT *, enum mode); +void logname(struct pinfo *, VARENT *, enum mode); +void longtname(struct pinfo *, VARENT *, enum mode); +void lname(struct pinfo *, VARENT *, enum mode); +void lstarted(struct pinfo *, VARENT *, enum mode); +void lstate(struct pinfo *, VARENT *, enum mode); +void maxrss(struct pinfo *, VARENT *, enum mode); void nlisterr(struct nlist *); -void p_rssize(void *, VARENT *, enum mode); -void pagein(void *, VARENT *, enum mode); +void p_rssize(struct pinfo *, VARENT *, enum mode); +void pagein(struct pinfo *, VARENT *, enum mode); void parsefmt(const char *); void parsefmt_insert(const char *, VARENT **); void parsesort(const char *); VARENT * varlist_find(VARLIST *, const char *); -void emul(void *, VARENT *, enum mode); -void pcpu(void *, VARENT *, enum mode); -void pmem(void *, VARENT *, enum mode); -void pnice(void *, VARENT *, enum mode); -void pri(void *, VARENT *, enum mode); +void emul(struct pinfo *, VARENT *, enum mode); +void pcpu(struct pinfo *, VARENT *, enum mode); +void pmem(struct pinfo *, VARENT *, enum mode); +void pnice(struct pinfo *, VARENT *, enum mode); +void pri(struct pinfo *, VARENT *, enum mode); void printheader(void); -void putimeval(void *, VARENT *, enum mode); -void pvar(void *, VARENT *, enum mode); -void rgname(void *, VARENT *, enum mode); -void rssize(void *, VARENT *, enum mode); -void runame(void *, VARENT *, enum mode); +void putimeval(struct pinfo *, VARENT *, enum mode); +void pvar(struct pinfo *, VARENT *, enum mode); +void rgname(struct pinfo *, VARENT *, enum mode); +void rssize(struct pinfo *, VARENT *, enum mode); +void runame(struct pinfo *, VARENT *, enum mode); void showkey(void); -void started(void *, VARENT *, enum mode); -void state(void *, VARENT *, enum mode); -void svgname(void *, VARENT *, enum mode); -void svuname(void *, VARENT *, enum mode); -void tdev(void *, VARENT *, enum mode); -void tname(void *, VARENT *, enum mode); -void tsize(void *, VARENT *, enum mode); -void ucomm(void *, VARENT *, enum mode); -void uname(void *, VARENT *, enum mode); -void uvar(void *, VARENT *, enum mode); -void vsize(void *, VARENT *, enum mode); -void wchan(void *, VARENT *, enum mode); +void started(struct pinfo *, VARENT *, enum mode); +void state(struct pinfo *, VARENT *, enum mode); +void svgname(struct pinfo *, VARENT *, enum mode); +void svuname(struct pinfo *, VARENT *, enum mode); +void tdev(struct pinfo *, VARENT *, enum mode); +void tname(struct pinfo *, VARENT *, enum mode); +void tsize(struct pinfo *, VARENT *, enum mode); +void ucomm(struct pinfo *, VARENT *, enum mode); +void uname(struct pinfo *,
CVS commit: src/bin/ps
Module Name:src Committed By: rin Date: Mon Nov 28 08:21:10 UTC 2016 Modified Files: src/bin/ps: extern.h print.c ps.c ps.h Log Message: Calculate CPU usage (pcpu) once per process if it is required. This change significantly improves performance for slow machines when output is sorted by pcpu. ok martin To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/bin/ps/extern.h cvs rdiff -u -r1.124 -r1.125 src/bin/ps/print.c cvs rdiff -u -r1.85 -r1.86 src/bin/ps/ps.c cvs rdiff -u -r1.27 -r1.28 src/bin/ps/ps.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/extern.h diff -u src/bin/ps/extern.h:1.36 src/bin/ps/extern.h:1.37 --- src/bin/ps/extern.h:1.36 Mon Nov 28 08:19:23 2016 +++ src/bin/ps/extern.h Mon Nov 28 08:21:10 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.36 2016/11/28 08:19:23 rin Exp $ */ +/* $NetBSD: extern.h,v 1.37 2016/11/28 08:21:10 rin Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -37,7 +37,7 @@ */ extern double log_ccpu; -extern int eval, fscale, mempages, nlistread, rawcpu, maxslp, uspace; +extern int eval, fscale, mempages, nlistread, maxslp, uspace; extern int sumrusage, termwidth, totwidth; extern int needenv, needcomm, commandonly; extern uid_t myuid; Index: src/bin/ps/print.c diff -u src/bin/ps/print.c:1.124 src/bin/ps/print.c:1.125 --- src/bin/ps/print.c:1.124 Mon Nov 28 08:19:23 2016 +++ src/bin/ps/print.c Mon Nov 28 08:21:10 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.124 2016/11/28 08:19:23 rin Exp $ */ +/* $NetBSD: print.c,v 1.125 2016/11/28 08:21:10 rin Exp $ */ /* * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: print.c,v 1.124 2016/11/28 08:19:23 rin Exp $"); +__RCSID("$NetBSD: print.c,v 1.125 2016/11/28 08:21:10 rin Exp $"); #endif #endif /* not lint */ @@ -1091,33 +1091,14 @@ lcputime(void *arg, VARENT *ve, enum mod cputime1(secs, psecs, v, mode); } -double -getpcpu(const struct kinfo_proc2 *k) -{ - - if (!nlistread) - donlist(); - -#define fxtofl(fixpt) ((double)(fixpt) / fscale) - - if (k->p_swtime == 0 || k->p_realstat == SZOMB) - return (0.0); - if (rawcpu) - return (100.0 * fxtofl(k->p_pctcpu)); - return (100.0 * fxtofl(k->p_pctcpu) / - (1.0 - exp(k->p_swtime * log_ccpu))); -} - void pcpu(void *arg, VARENT *ve, enum mode mode) { - struct kinfo_proc2 *k; VAR *v; double dbl; - k = arg; v = ve->var; - dbl = getpcpu(k); + dbl = ((struct pinfo *)arg)->pcpu; doubleprintorsetwidth(v, dbl, (dbl >= 99.95) ? 0 : 1, mode); } Index: src/bin/ps/ps.c diff -u src/bin/ps/ps.c:1.85 src/bin/ps/ps.c:1.86 --- src/bin/ps/ps.c:1.85 Mon Nov 28 08:18:27 2016 +++ src/bin/ps/ps.c Mon Nov 28 08:21:10 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ps.c,v 1.85 2016/11/28 08:18:27 rin Exp $ */ +/* $NetBSD: ps.c,v 1.86 2016/11/28 08:21:10 rin Exp $ */ /* * Copyright (c) 2000-2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: ps.c,v 1.85 2016/11/28 08:18:27 rin Exp $"); +__RCSID("$NetBSD: ps.c,v 1.86 2016/11/28 08:21:10 rin Exp $"); #endif #endif /* not lint */ @@ -89,6 +89,7 @@ __RCSID("$NetBSD: ps.c,v 1.85 2016/11/28 #include #include #include +#include #include #include #include @@ -106,12 +107,10 @@ __RCSID("$NetBSD: ps.c,v 1.85 2016/11/28 #define GETOPTSTR "aAcCeghjk:LlM:mN:O:o:p:rSsTt:U:uvW:wx" #define ARGOPTS "kMNOopUW" -struct kinfo_proc2 *kinfo; struct varlist displaylist = SIMPLEQ_HEAD_INITIALIZER(displaylist); struct varlist sortlist = SIMPLEQ_HEAD_INITIALIZER(sortlist); int eval; /* exit value */ -int rawcpu; /* -C */ int sumrusage; /* -S */ int termwidth; /* width of screen (0 == infinity) */ int totwidth; /* calculated width of requested variables */ @@ -124,6 +123,8 @@ static struct kinfo_lwp struct kinfo_lwp *, int); static struct kinfo_proc2 *getkinfo_kvm(kvm_t *, int, int, int *); +static struct pinfo + *setpinfo(struct kinfo_proc2 *, int, int, int); static char *kludge_oldps_options(char *); static int pscomp(const void *, const void *); static void scanvars(void); @@ -197,12 +198,14 @@ ttyname2dev(const char *ttname, int *xfl int main(int argc, char *argv[]) { + struct kinfo_proc2 *kinfo; + struct pinfo *pinfo; struct varent *vent; struct winsize ws; struct kinfo_lwp *kl, *l; int ch, i, j, fmt, lineno, nentries, nlwps; long long flag; - int prtheader, wflag, what, xflg, showlwps; + int calc_pcpu, prtheader, wflag, what, xflg, rawcpu, showlwps; char *nlistf, *memf, *swapf, errbuf[_POSIX2_LINE_MAX]; char *ttname; @@ -394,11 +397,20 @@ main(int argc, char *argv[]) /* Add default sort criteria */ parsesort("tdev,pid"); + calc_pcpu = 0; SIMPLEQ_FOREACH(vent, &sortlist, next) { i
CVS commit: src/bin/ps
Module Name:src Committed By: rin Date: Mon Nov 28 08:19:23 UTC 2016 Modified Files: src/bin/ps: extern.h nlist.c print.c Log Message: for donlist{,_sysctl}: - obtain log_ccpu = log(ccpu) rather than ccpu itself - use common default values and warn users appropriately when errors occur ok martin To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/bin/ps/extern.h cvs rdiff -u -r1.26 -r1.27 src/bin/ps/nlist.c cvs rdiff -u -r1.123 -r1.124 src/bin/ps/print.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/extern.h diff -u src/bin/ps/extern.h:1.35 src/bin/ps/extern.h:1.36 --- src/bin/ps/extern.h:1.35 Sun Apr 20 22:48:59 2014 +++ src/bin/ps/extern.h Mon Nov 28 08:19:23 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.35 2014/04/20 22:48:59 dholland Exp $ */ +/* $NetBSD: extern.h,v 1.36 2016/11/28 08:19:23 rin Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -36,7 +36,7 @@ * defined the types we use. */ -extern double ccpu; +extern double log_ccpu; extern int eval, fscale, mempages, nlistread, rawcpu, maxslp, uspace; extern int sumrusage, termwidth, totwidth; extern int needenv, needcomm, commandonly; @@ -49,8 +49,8 @@ extern VARLIST sortlist; void command(void *, VARENT *, enum mode); void cpuid(void *, VARENT *, enum mode); void cputime(void *, VARENT *, enum mode); -int donlist(void); -int donlist_sysctl(void); +void donlist(void); +void donlist_sysctl(void); void fmt_puts(char *, int *); void fmt_putc(int, int *); void elapsed(void *, VARENT *, enum mode); Index: src/bin/ps/nlist.c diff -u src/bin/ps/nlist.c:1.26 src/bin/ps/nlist.c:1.27 --- src/bin/ps/nlist.c:1.26 Mon Apr 28 20:22:51 2008 +++ src/bin/ps/nlist.c Mon Nov 28 08:19:23 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: nlist.c,v 1.26 2008/04/28 20:22:51 martin Exp $ */ +/* $NetBSD: nlist.c,v 1.27 2016/11/28 08:19:23 rin Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)nlist.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: nlist.c,v 1.26 2008/04/28 20:22:51 martin Exp $"); +__RCSID("$NetBSD: nlist.c,v 1.27 2016/11/28 08:19:23 rin Exp $"); #endif #endif /* not lint */ @@ -97,50 +97,73 @@ struct nlist psnl[] = { { .n_name = NULL } }; -double ccpu;/* kernel _ccpu variable */ +double log_ccpu; /* log of kernel _ccpu variable */ int nlistread; /* if nlist already read. */ int mempages; /* number of pages of phys. memory */ int fscale;/* kernel _fscale variable */ int maxslp;/* kernel _maxslp variable */ int uspace;/* kernel USPACE value */ +/* XXX Hopefully reasonable default */ +#define MEMPAGES 0 +#ifndef FSCALE +#define FSCALE (1 << 8) +#endif +#define LOG_CCPU (-1.0 / 20.0) +#ifndef MAXSLP +#define MAXSLP 20 +#endif +#ifndef USPACE +#define USPACE (getpagesize()) +#endif + #define kread(x, v) \ kvm_read(kd, psnl[x].n_value, (char *)&v, sizeof v) != sizeof(v) -int +void donlist(void) { - int rval; fixpt_t xccpu; - rval = 0; nlistread = 1; + if (kvm_nlist(kd, psnl)) { nlisterr(psnl); eval = 1; - return (1); + fscale = FSCALE; + mempages = MEMPAGES; + log_ccpu = LOG_CCPU; + maxslp = MAXSLP; + return; } + if (kread(X_FSCALE, fscale)) { warnx("fscale: %s", kvm_geterr(kd)); - eval = rval = 1; + eval = 1; + fscale = FSCALE; } + if (kread(X_PHYSMEM, mempages)) { warnx("avail_start: %s", kvm_geterr(kd)); - eval = rval = 1; + eval = 1; + mempages = MEMPAGES; } + if (kread(X_CCPU, xccpu)) { warnx("ccpu: %s", kvm_geterr(kd)); - eval = rval = 1; - } + eval = 1; + log_ccpu = LOG_CCPU; + } else + log_ccpu = log((double)xccpu / fscale); + if (kread(X_MAXSLP, maxslp)) { warnx("maxslp: %s", kvm_geterr(kd)); - eval = rval = 1; + eval = 1; + maxslp = MAXSLP; } - ccpu = (double)xccpu / fscale; - return (rval); } -int +void donlist_sysctl(void) { int mib[2]; @@ -149,49 +172,53 @@ donlist_sysctl(void) uint64_t memsize; nlistread = 1; - mib[0] = CTL_HW; - mib[1] = HW_PHYSMEM64; - size = sizeof(memsize); - if (sysctl(mib, 2, &memsize, &size, NULL, 0) == 0) - mempages = memsize / getpagesize(); - else - mempages = 0; mib[0] = CTL_KERN; mib[1] = KERN_FSCALE; size = sizeof(fscale); - if (sysctl(mib, 2, &fscale, &size, NULL, 0) == -1) - fscale = (1 << 8); /* XXX Hopefully reasonable default */ + if (sysctl(mib, 2, &fscale, &size, NULL, 0)) { + warn("fscale"); + eval = 1; + fscale = FSCALE; + } + + mib[0] = CTL_HW; + mib[1] = HW_PHYSMEM64; + size = sizeof(memsize); + if (sysctl(mib, 2, &memsize, &size, NULL, 0)) { + warn("avail_start"); + eval = 1; + mempages = MEMPAGES; + } else + mempages = memsize / getpagesize(); mib[0] = CTL_KERN; mib[1] = KERN_CCPU; size = sizeof(xccpu); - if (sysctl(mib, 2, &xccpu, &size, NULL, 0) == -1) - ccpu = exp(-1.0 / 20.0); /* XXX Hopefully reasonable default */ - else - ccpu
CVS commit: src/bin/ps
Module Name:src Committed By: rin Date: Mon Nov 28 08:18:27 UTC 2016 Modified Files: src/bin/ps: ps.c Log Message: KNF ok martin To generate a diff of this commit: cvs rdiff -u -r1.84 -r1.85 src/bin/ps/ps.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.c diff -u src/bin/ps/ps.c:1.84 src/bin/ps/ps.c:1.85 --- src/bin/ps/ps.c:1.84 Mon Sep 5 01:00:07 2016 +++ src/bin/ps/ps.c Mon Nov 28 08:18:27 2016 @@ -1,4 +1,4 @@ -/* $NetBSD: ps.c,v 1.84 2016/09/05 01:00:07 sevan Exp $ */ +/* $NetBSD: ps.c,v 1.85 2016/11/28 08:18:27 rin Exp $ */ /* * Copyright (c) 2000-2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: ps.c,v 1.84 2016/09/05 01:00:07 sevan Exp $"); +__RCSID("$NetBSD: ps.c,v 1.85 2016/11/28 08:18:27 rin Exp $"); #endif #endif /* not lint */ @@ -261,8 +261,7 @@ main(int argc, char *argv[]) break; /* no-op - was dontuseprocfs */ case 'L': showkey(); - exit(0); - /* NOTREACHED */ + return 0; case 'l': parsefmt(lfmt); fmt = 1; @@ -387,7 +386,7 @@ main(int argc, char *argv[]) } else kd = kvm_openfiles(nlistf, memf, swapf, O_RDONLY, errbuf); - if (kd == 0) + if (kd == NULL) errx(1, "%s", errbuf); if (!fmt) @@ -413,7 +412,7 @@ main(int argc, char *argv[]) err(1, "%s", kvm_geterr(kd)); if (nentries == 0) { printheader(); - exit(1); + return 1; } /* * sort proc list @@ -499,8 +498,7 @@ main(int argc, char *argv[]) } } } - exit(eval); - /* NOTREACHED */ + return eval; } static struct kinfo_lwp * @@ -561,7 +559,6 @@ pick_representative_lwp(struct kinfo_pro return kl; } - static struct kinfo_proc2 * getkinfo_kvm(kvm_t *kdp, int what, int flag, int *nentriesp) {
CVS commit: src/bin/ps
Module Name:src Committed By: sevan Date: Wed Aug 10 22:00:56 UTC 2016 Modified Files: src/bin/ps: ps.1 Log Message: Earliest reference in the TUHS archive is v3 Unfortunately only the source code for the compiler is present for that release. The v2 archive is missing the manuals & only contains a some of the commands. Switch to v3 and reference manual category eight, as per r1.32 of src/bin/ps/ps.1 from OpenBSD. Heads up from Ingo Schwarze. To generate a diff of this commit: cvs rdiff -u -r1.104 -r1.105 src/bin/ps/ps.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.1 diff -u src/bin/ps/ps.1:1.104 src/bin/ps/ps.1:1.105 --- src/bin/ps/ps.1:1.104 Wed Aug 10 18:44:50 2016 +++ src/bin/ps/ps.1 Wed Aug 10 22:00:56 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: ps.1,v 1.104 2016/08/10 18:44:50 sevan Exp $ +.\" $NetBSD: ps.1,v 1.105 2016/08/10 22:00:56 sevan Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -705,7 +705,8 @@ default system name list A .Nm utility appeared in -.At v4 . +.At v3 +in section 8 of the manual. .Sh BUGS Since .Nm
CVS commit: src/bin/ps
Module Name:src Committed By: sevan Date: Wed Aug 10 18:44:50 UTC 2016 Modified Files: src/bin/ps: ps.1 Log Message: Document the version ps first appeared. To generate a diff of this commit: cvs rdiff -u -r1.103 -r1.104 src/bin/ps/ps.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.1 diff -u src/bin/ps/ps.1:1.103 src/bin/ps/ps.1:1.104 --- src/bin/ps/ps.1:1.103 Wed Jan 15 09:24:31 2014 +++ src/bin/ps/ps.1 Wed Aug 10 18:44:50 2016 @@ -1,4 +1,4 @@ -.\" $NetBSD: ps.1,v 1.103 2014/01/15 09:24:31 wiz Exp $ +.\" $NetBSD: ps.1,v 1.104 2016/08/10 18:44:50 sevan Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)ps.1 8.3 (Berkeley) 4/18/94 .\" -.Dd January 15, 2014 +.Dd August 10, 2016 .Dt PS 1 .Os .Sh NAME @@ -701,6 +701,11 @@ default system name list .Xr strftime 3 , .Xr dev_mkdb 8 , .Xr pstat 8 +.Sh HISTORY +A +.Nm +utility appeared in +.At v4 . .Sh BUGS Since .Nm
CVS commit: src/bin/ps
Module Name:src Committed By: joerg Date: Sat Nov 15 01:58:34 UTC 2014 Modified Files: src/bin/ps: print.c Log Message: Use l_wmesg if the string is not empty. Don't bother checking l_name for nullness. To generate a diff of this commit: cvs rdiff -u -r1.122 -r1.123 src/bin/ps/print.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/print.c diff -u src/bin/ps/print.c:1.122 src/bin/ps/print.c:1.123 --- src/bin/ps/print.c:1.122 Sun Apr 20 22:48:59 2014 +++ src/bin/ps/print.c Sat Nov 15 01:58:34 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.122 2014/04/20 22:48:59 dholland Exp $ */ +/* $NetBSD: print.c,v 1.123 2014/11/15 01:58:34 joerg Exp $ */ /* * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: print.c,v 1.122 2014/04/20 22:48:59 dholland Exp $"); +__RCSID("$NetBSD: print.c,v 1.123 2014/11/15 01:58:34 joerg Exp $"); #endif #endif /* not lint */ @@ -947,7 +947,7 @@ wchan(void *arg, VARENT *ve, enum mode m l = arg; v = ve->var; if (l->l_wchan) { - if (l->l_wmesg) { + if (l->l_wmesg[0]) { strprintorsetwidth(v, l->l_wmesg, mode); v->width = min(v->width, KI_WMESGLEN); } else { @@ -1464,7 +1464,7 @@ lname(void *arg, VARENT *ve, enum mode m l = arg; v = ve->var; - if (l->l_name && l->l_name[0] != '\0') { + if (l->l_name[0] != '\0') { strprintorsetwidth(v, l->l_name, mode); v->width = min(v->width, KI_LNAMELEN); } else {
CVS commit: src/bin/ps
Module Name:src Committed By: dholland Date: Sat Jun 28 17:32:27 UTC 2014 Modified Files: src/bin/ps: ps.c Log Message: Don't print junk errnos. Avoids: % ps -tfoo ps: /dev/ttyfoo: Undefined error: 0 Exit 1 To generate a diff of this commit: cvs rdiff -u -r1.81 -r1.82 src/bin/ps/ps.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.c diff -u src/bin/ps/ps.c:1.81 src/bin/ps/ps.c:1.82 --- src/bin/ps/ps.c:1.81 Sun Apr 20 23:31:40 2014 +++ src/bin/ps/ps.c Sat Jun 28 17:32:27 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ps.c,v 1.81 2014/04/20 23:31:40 dholland Exp $ */ +/* $NetBSD: ps.c,v 1.82 2014/06/28 17:32:27 dholland Exp $ */ /* * Copyright (c) 2000-2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: ps.c,v 1.81 2014/04/20 23:31:40 dholland Exp $"); +__RCSID("$NetBSD: ps.c,v 1.82 2014/06/28 17:32:27 dholland Exp $"); #endif #endif /* not lint */ @@ -175,8 +175,11 @@ ttyname2dev(const char *ttname, int *xfl ttypath = ttname; *what = KERN_PROC_TTY; if (stat(ttypath, &sb) == -1) { - devmajor_t pts = getdevmajor("pts", S_IFCHR); + devmajor_t pts; + int serrno; + serrno = errno; + pts = getdevmajor("pts", S_IFCHR); if (pts != NODEVMAJOR && strncmp(ttname, "pts/", 4) == 0) { int ptsminor = atoi(ttname + 4); @@ -184,6 +187,7 @@ ttyname2dev(const char *ttname, int *xfl if (strcmp(pathbuf, ttname) == 0 && ptsminor >= 0) return makedev(pts, ptsminor); } + errno = serrno; err(1, "%s", ttypath); } if (!S_ISCHR(sb.st_mode))
CVS commit: src/bin/ps
Module Name:src Committed By: dholland Date: Sun Apr 20 23:31:40 UTC 2014 Modified Files: src/bin/ps: ps.c Log Message: Don't bother using variables whose value is never changed from the initialization value. To generate a diff of this commit: cvs rdiff -u -r1.80 -r1.81 src/bin/ps/ps.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.c diff -u src/bin/ps/ps.c:1.80 src/bin/ps/ps.c:1.81 --- src/bin/ps/ps.c:1.80 Wed Feb 19 20:42:14 2014 +++ src/bin/ps/ps.c Sun Apr 20 23:31:40 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ps.c,v 1.80 2014/02/19 20:42:14 dsl Exp $ */ +/* $NetBSD: ps.c,v 1.81 2014/04/20 23:31:40 dholland Exp $ */ /* * Copyright (c) 2000-2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: ps.c,v 1.80 2014/02/19 20:42:14 dsl Exp $"); +__RCSID("$NetBSD: ps.c,v 1.81 2014/04/20 23:31:40 dholland Exp $"); #endif #endif /* not lint */ @@ -199,7 +199,7 @@ main(int argc, char *argv[]) struct kinfo_lwp *kl, *l; int ch, i, j, fmt, lineno, nentries, nlwps; long long flag; - int prtheader, wflag, what, xflg, mode, showlwps; + int prtheader, wflag, what, xflg, showlwps; char *nlistf, *memf, *swapf, errbuf[_POSIX2_LINE_MAX]; char *ttname; @@ -221,7 +221,7 @@ main(int argc, char *argv[]) what = KERN_PROC_UID; flag = myuid = getuid(); memf = nlistf = swapf = NULL; - mode = PRINTMODE; + while ((ch = getopt(argc, argv, GETOPTSTR)) != -1) switch((char)ch) { case 'A': @@ -421,33 +421,32 @@ main(int argc, char *argv[]) * "setwidth" mode to determine the widest element of * the column. */ - if (mode == PRINTMODE) - for (i = 0; i < nentries; i++) { - struct kinfo_proc2 *ki = &kinfo[i]; - - if (xflg == 0 && (ki->p_tdev == (uint32_t)NODEV || - (ki->p_flag & P_CONTROLT) == 0)) -continue; - - kl = kvm_getlwps(kd, ki->p_pid, ki->p_paddr, - sizeof(struct kinfo_lwp), &nlwps); - if (kl == 0) -nlwps = 0; - if (showlwps == 0) { -l = pick_representative_lwp(ki, kl, nlwps); -SIMPLEQ_FOREACH(vent, &displaylist, next) - OUTPUT(vent, ki, l, WIDTHMODE); - } else { -/* The printing is done with the loops - * reversed, but here we don't need that, - * and this improves the code locality a bit. - */ -SIMPLEQ_FOREACH(vent, &displaylist, next) - for (j = 0; j < nlwps; j++) - OUTPUT(vent, ki, &kl[j], - WIDTHMODE); - } + + for (i = 0; i < nentries; i++) { + struct kinfo_proc2 *ki = &kinfo[i]; + + if (xflg == 0 && (ki->p_tdev == (uint32_t)NODEV || + (ki->p_flag & P_CONTROLT) == 0)) + continue; + + kl = kvm_getlwps(kd, ki->p_pid, ki->p_paddr, + sizeof(struct kinfo_lwp), &nlwps); + if (kl == 0) + nlwps = 0; + if (showlwps == 0) { + l = pick_representative_lwp(ki, kl, nlwps); + SIMPLEQ_FOREACH(vent, &displaylist, next) +OUTPUT(vent, ki, l, WIDTHMODE); + } else { + /* The printing is done with the loops + * reversed, but here we don't need that, + * and this improves the code locality a bit. + */ + SIMPLEQ_FOREACH(vent, &displaylist, next) +for (j = 0; j < nlwps; j++) + OUTPUT(vent, ki, &kl[j], WIDTHMODE); } + } /* * Print header - AFTER determining process field widths. * printheader() also adds up the total width of all @@ -471,7 +470,7 @@ main(int argc, char *argv[]) if (showlwps == 0) { l = pick_representative_lwp(ki, kl, nlwps); SIMPLEQ_FOREACH(vent, &displaylist, next) { -OUTPUT(vent, ki, l, mode); +OUTPUT(vent, ki, l, PRINTMODE); if (SIMPLEQ_NEXT(vent, next) != NULL) (void)putchar(' '); } @@ -484,7 +483,7 @@ main(int argc, char *argv[]) } else { for (j = 0; j < nlwps; j++) { SIMPLEQ_FOREACH(vent, &displaylist, next) { - OUTPUT(vent, ki, &kl[j], mode); + OUTPUT(vent, ki, &kl[j], PRINTMODE); if (SIMPLEQ_NEXT(vent, next) != NULL) (void)putchar(' '); }
CVS commit: src/bin/ps
Module Name:src Committed By: dholland Date: Sun Apr 20 22:48:59 UTC 2014 Modified Files: src/bin/ps: extern.h print.c ps.h Log Message: Use an enum type for PRINTMODE vs. WIDTHMODE. Compiler output diffs have been checked. To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/bin/ps/extern.h cvs rdiff -u -r1.121 -r1.122 src/bin/ps/print.c cvs rdiff -u -r1.26 -r1.27 src/bin/ps/ps.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/extern.h diff -u src/bin/ps/extern.h:1.34 src/bin/ps/extern.h:1.35 --- src/bin/ps/extern.h:1.34 Wed Jan 15 08:07:53 2014 +++ src/bin/ps/extern.h Sun Apr 20 22:48:59 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.34 2014/01/15 08:07:53 mlelstv Exp $ */ +/* $NetBSD: extern.h,v 1.35 2014/04/20 22:48:59 dholland Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -46,54 +46,54 @@ extern VAR var[]; extern VARLIST displaylist; extern VARLIST sortlist; -void command(void *, VARENT *, int); -void cpuid(void *, VARENT *, int); -void cputime(void *, VARENT *, int); +void command(void *, VARENT *, enum mode); +void cpuid(void *, VARENT *, enum mode); +void cputime(void *, VARENT *, enum mode); int donlist(void); int donlist_sysctl(void); void fmt_puts(char *, int *); void fmt_putc(int, int *); -void elapsed(void *, VARENT *, int); +void elapsed(void *, VARENT *, enum mode); double getpcpu(const struct kinfo_proc2 *); double getpmem(const struct kinfo_proc2 *); -void gname(void *, VARENT *, int); -void groups(void *, VARENT *, int); -void groupnames(void *, VARENT *, int); -void lcputime(void *, VARENT *, int); -void logname(void *, VARENT *, int); -void longtname(void *, VARENT *, int); -void lname(void *, VARENT *, int); -void lstarted(void *, VARENT *, int); -void lstate(void *, VARENT *, int); -void maxrss(void *, VARENT *, int); +void gname(void *, VARENT *, enum mode); +void groups(void *, VARENT *, enum mode); +void groupnames(void *, VARENT *, enum mode); +void lcputime(void *, VARENT *, enum mode); +void logname(void *, VARENT *, enum mode); +void longtname(void *, VARENT *, enum mode); +void lname(void *, VARENT *, enum mode); +void lstarted(void *, VARENT *, enum mode); +void lstate(void *, VARENT *, enum mode); +void maxrss(void *, VARENT *, enum mode); void nlisterr(struct nlist *); -void p_rssize(void *, VARENT *, int); -void pagein(void *, VARENT *, int); +void p_rssize(void *, VARENT *, enum mode); +void pagein(void *, VARENT *, enum mode); void parsefmt(const char *); void parsefmt_insert(const char *, VARENT **); void parsesort(const char *); VARENT * varlist_find(VARLIST *, const char *); -void emul(void *, VARENT *, int); -void pcpu(void *, VARENT *, int); -void pmem(void *, VARENT *, int); -void pnice(void *, VARENT *, int); -void pri(void *, VARENT *, int); +void emul(void *, VARENT *, enum mode); +void pcpu(void *, VARENT *, enum mode); +void pmem(void *, VARENT *, enum mode); +void pnice(void *, VARENT *, enum mode); +void pri(void *, VARENT *, enum mode); void printheader(void); -void putimeval(void *, VARENT *, int); -void pvar(void *, VARENT *, int); -void rgname(void *, VARENT *, int); -void rssize(void *, VARENT *, int); -void runame(void *, VARENT *, int); +void putimeval(void *, VARENT *, enum mode); +void pvar(void *, VARENT *, enum mode); +void rgname(void *, VARENT *, enum mode); +void rssize(void *, VARENT *, enum mode); +void runame(void *, VARENT *, enum mode); void showkey(void); -void started(void *, VARENT *, int); -void state(void *, VARENT *, int); -void svgname(void *, VARENT *, int); -void svuname(void *, VARENT *, int); -void tdev(void *, VARENT *, int); -void tname(void *, VARENT *, int); -void tsize(void *, VARENT *, int); -void ucomm(void *, VARENT *, int); -void uname(void *, VARENT *, int); -void uvar(void *, VARENT *, int); -void vsize(void *, VARENT *, int); -void wchan(void *, VARENT *, int); +void started(void *, VARENT *, enum mode); +void state(void *, VARENT *, enum mode); +void svgname(void *, VARENT *, enum mode); +void svuname(void *, VARENT *, enum mode); +void tdev(void *, VARENT *, enum mode); +void tname(void *, VARENT *, enum mode); +void tsize(void *, VARENT *, enum mode); +void ucomm(void *, VARENT *, enum mode); +void uname(void *, VARENT *, enum mode); +void uvar(void *, VARENT *, enum mode); +void vsize(void *, VARENT *, enum mode); +void wchan(void *, VARENT *, enum mode); Index: src/bin/ps/print.c diff -u src/bin/ps/print.c:1.121 src/bin/ps/print.c:1.122 --- src/bin/ps/print.c:1.121 Wed Jan 15 08:07:53 2014 +++ src/bin/ps/print.c Sun Apr 20 22:48:59 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.121 2014/01/15 08:07:53 mlelstv Exp $ */ +/* $NetBSD: print.c,v 1.122 2014/04/20 22:48:59 dholland Exp $ */ /* * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@
CVS commit: src/bin/ps
Module Name:src Committed By: wiz Date: Wed Jan 15 09:24:31 UTC 2014 Modified Files: src/bin/ps: ps.1 Log Message: Bump date for previous. To generate a diff of this commit: cvs rdiff -u -r1.102 -r1.103 src/bin/ps/ps.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.1 diff -u src/bin/ps/ps.1:1.102 src/bin/ps/ps.1:1.103 --- src/bin/ps/ps.1:1.102 Wed Jan 15 08:07:53 2014 +++ src/bin/ps/ps.1 Wed Jan 15 09:24:31 2014 @@ -1,4 +1,4 @@ -.\" $NetBSD: ps.1,v 1.102 2014/01/15 08:07:53 mlelstv Exp $ +.\" $NetBSD: ps.1,v 1.103 2014/01/15 09:24:31 wiz Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)ps.1 8.3 (Berkeley) 4/18/94 .\" -.Dd March 15, 2012 +.Dd January 15, 2014 .Dt PS 1 .Os .Sh NAME
CVS commit: src/bin/ps
Module Name:src Committed By: mlelstv Date: Wed Jan 15 08:09:10 UTC 2014 Modified Files: src/bin/ps: ps.c Log Message: Make ps -s use LTIME instead of TIME in the default output format. To generate a diff of this commit: cvs rdiff -u -r1.78 -r1.79 src/bin/ps/ps.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.c diff -u src/bin/ps/ps.c:1.78 src/bin/ps/ps.c:1.79 --- src/bin/ps/ps.c:1.78 Mon May 7 13:14:31 2012 +++ src/bin/ps/ps.c Wed Jan 15 08:09:10 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: ps.c,v 1.78 2012/05/07 13:14:31 joerg Exp $ */ +/* $NetBSD: ps.c,v 1.79 2014/01/15 08:09:10 mlelstv Exp $ */ /* * Copyright (c) 2000-2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: ps.c,v 1.78 2012/05/07 13:14:31 joerg Exp $"); +__RCSID("$NetBSD: ps.c,v 1.79 2014/01/15 08:09:10 mlelstv Exp $"); #endif #endif /* not lint */ @@ -136,7 +136,7 @@ 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 sfmt[] = "uid pid ppid cpu lid nlwp pri nice vsz rss wchan lstate tt " - "time command"; + "ltime 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";
CVS commit: src/bin/ps
Module Name:src Committed By: mlelstv Date: Wed Jan 15 08:07:53 UTC 2014 Modified Files: src/bin/ps: extern.h keyword.c print.c ps.1 Log Message: Add an LTIME column that prints lwp cputime. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/bin/ps/extern.h cvs rdiff -u -r1.53 -r1.54 src/bin/ps/keyword.c cvs rdiff -u -r1.120 -r1.121 src/bin/ps/print.c cvs rdiff -u -r1.101 -r1.102 src/bin/ps/ps.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/extern.h diff -u src/bin/ps/extern.h:1.33 src/bin/ps/extern.h:1.34 --- src/bin/ps/extern.h:1.33 Mon May 31 03:18:33 2010 +++ src/bin/ps/extern.h Wed Jan 15 08:07:53 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.33 2010/05/31 03:18:33 rmind Exp $ */ +/* $NetBSD: extern.h,v 1.34 2014/01/15 08:07:53 mlelstv Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -59,6 +59,7 @@ double getpmem(const struct kinfo_proc2 void gname(void *, VARENT *, int); void groups(void *, VARENT *, int); void groupnames(void *, VARENT *, int); +void lcputime(void *, VARENT *, int); void logname(void *, VARENT *, int); void longtname(void *, VARENT *, int); void lname(void *, VARENT *, int); Index: src/bin/ps/keyword.c diff -u src/bin/ps/keyword.c:1.53 src/bin/ps/keyword.c:1.54 --- src/bin/ps/keyword.c:1.53 Wed Oct 21 21:11:57 2009 +++ src/bin/ps/keyword.c Wed Jan 15 08:07:53 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: keyword.c,v 1.53 2009/10/21 21:11:57 rmind Exp $ */ +/* $NetBSD: keyword.c,v 1.54 2014/01/15 08:07:53 mlelstv Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)keyword.c 8.5 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: keyword.c,v 1.53 2009/10/21 21:11:57 rmind Exp $"); +__RCSID("$NetBSD: keyword.c,v 1.54 2014/01/15 08:07:53 mlelstv Exp $"); #endif #endif /* not lint */ @@ -149,6 +149,7 @@ VAR var[] = { VAR3("logname", "login", ALIAS), VAR6("lstart", "STARTED", LJUST, lstarted, POFF(p_ustart_sec), UINT32), VAR4("lstate", "STAT", LJUST|LWP, lstate), + VAR6("ltime", "LTIME", LWP, lcputime, 0, CPUTIME), PUVAR("majflt", "MAJFLT", 0, p_uru_majflt, UINT64, PRIu64), PUVAR("minflt", "MINFLT", 0, p_uru_minflt, UINT64, PRIu64), PUVAR("msgrcv", "MSGRCV", 0, p_uru_msgrcv, UINT64, PRIu64), Index: src/bin/ps/print.c diff -u src/bin/ps/print.c:1.120 src/bin/ps/print.c:1.121 --- src/bin/ps/print.c:1.120 Tue Mar 20 18:42:28 2012 +++ src/bin/ps/print.c Wed Jan 15 08:07:53 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.120 2012/03/20 18:42:28 matt Exp $ */ +/* $NetBSD: print.c,v 1.121 2014/01/15 08:07:53 mlelstv Exp $ */ /* * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: print.c,v 1.120 2012/03/20 18:42:28 matt Exp $"); +__RCSID("$NetBSD: print.c,v 1.121 2014/01/15 08:07:53 mlelstv Exp $"); #endif #endif /* not lint */ @@ -1012,29 +1012,11 @@ cpuid(void *arg, VARENT *ve, int mode) intprintorsetwidth(v, l->l_cpuid, mode); } -void -cputime(void *arg, VARENT *ve, int mode) +static void +cputime1(int32_t secs, int32_t psecs, VAR *v, int mode) { - struct kinfo_proc2 *k; - VAR *v; - int32_t secs; - int32_t psecs; /* "parts" of a second. first micro, then centi */ int fmtlen; - k = arg; - v = ve->var; - - /* - * This counts time spent handling interrupts. We could - * fix this, but it is not 100% trivial (and interrupt - * time fractions only work on the sparc anyway). XXX - */ - secs = k->p_rtime_sec; - psecs = k->p_rtime_usec; - if (sumrusage) { - secs += k->p_uctime_sec; - psecs += k->p_uctime_usec; - } /* * round and scale to 100's */ @@ -1066,6 +1048,49 @@ cputime(void *arg, VARENT *ve, int mode) } } +void +cputime(void *arg, VARENT *ve, int mode) +{ + struct kinfo_proc2 *k; + VAR *v; + int32_t secs; + int32_t psecs; /* "parts" of a second. first micro, then centi */ + + k = arg; + v = ve->var; + + /* + * This counts time spent handling interrupts. We could + * fix this, but it is not 100% trivial (and interrupt + * time fractions only work on the sparc anyway). XXX + */ + secs = k->p_rtime_sec; + psecs = k->p_rtime_usec; + if (sumrusage) { + secs += k->p_uctime_sec; + psecs += k->p_uctime_usec; + } + + cputime1(secs, psecs, v, mode); +} + +void +lcputime(void *arg, VARENT *ve, int mode) +{ + struct kinfo_lwp *l; + VAR *v; + int32_t secs; + int32_t psecs; /* "parts" of a second. first micro, then centi */ + + l = arg; + v = ve->var; + + secs = l->l_rtime_sec; + psecs = l->l_rtime_usec; + + cputime1(secs, psecs, v, mode); +} + double getpcpu(const struct kinfo_proc2 *k) { Index: src/bin/ps/ps.1 diff -u src/bin/ps/ps.1:1.101 src/bin/ps/ps.1:1.102 --- src/bin/ps/ps.1:1.101 Sun Jun 3 21:42:44 2012 +++ src/bin/ps/ps.1 Wed Jan 15 08:07:53 2014 @@ -1,4 +1,4 @@ -.\" $NetBSD: ps.1,v 1.101 2012/06/03 21:42:44 joerg Exp $ +.
CVS commit: src/bin/ps
Module Name:src Committed By: joerg Date: Mon May 7 13:14:31 UTC 2012 Modified Files: src/bin/ps: ps.c Log Message: Push logic to convert a ttyname to a device number into its own function. Improve dealing with ptyfs by explicitly handling missing pts/%d entries, if the kernel supports the pts device (PR 40813). To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/bin/ps/ps.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.c diff -u src/bin/ps/ps.c:1.77 src/bin/ps/ps.c:1.78 --- src/bin/ps/ps.c:1.77 Sun Apr 15 18:10:13 2012 +++ src/bin/ps/ps.c Mon May 7 13:14:31 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ps.c,v 1.77 2012/04/15 18:10:13 wiz Exp $ */ +/* $NetBSD: ps.c,v 1.78 2012/05/07 13:14:31 joerg Exp $ */ /* * Copyright (c) 2000-2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: ps.c,v 1.77 2012/04/15 18:10:13 wiz Exp $"); +__RCSID("$NetBSD: ps.c,v 1.78 2012/05/07 13:14:31 joerg Exp $"); #endif #endif /* not lint */ @@ -146,6 +146,52 @@ struct varent *Opos = NULL; /* -O flag i kvm_t *kd; +static long long +ttyname2dev(const char *ttname, int *xflg, int *what) +{ + struct stat sb; + const char *ttypath; + char pathbuf[MAXPATHLEN]; + + ttypath = NULL; + if (strcmp(ttname, "?") == 0) { + *xflg = 1; + return KERN_PROC_TTY_NODEV; + } + if (strcmp(ttname, "-") == 0) + return KERN_PROC_TTY_REVOKE; + + if (strcmp(ttname, "co") == 0) + ttypath = _PATH_CONSOLE; + else if (strncmp(ttname, "pts/", 4) == 0 || + strncmp(ttname, "tty", 3) == 0) { + (void)snprintf(pathbuf, + sizeof(pathbuf), "%s%s", _PATH_DEV, ttname); + ttypath = pathbuf; + } else if (*ttname != '/') { + (void)snprintf(pathbuf, + sizeof(pathbuf), "%s%s", _PATH_TTY, ttname); + ttypath = pathbuf; + } else + ttypath = ttname; + *what = KERN_PROC_TTY; + if (stat(ttypath, &sb) == -1) { + devmajor_t pts = getdevmajor("pts", S_IFCHR); + + if (pts != NODEVMAJOR && strncmp(ttname, "pts/", 4) == 0) { + int ptsminor = atoi(ttname + 4); + + snprintf(pathbuf, sizeof(pathbuf), "pts/%d", ptsminor); + if (strcmp(pathbuf, ttname) == 0 && ptsminor >= 0) +return makedev(pts, ptsminor); + } + err(1, "%s", ttypath); + } + if (!S_ISCHR(sb.st_mode)) + errx(1, "%s: not a terminal", ttypath); + return sb.st_rdev; +} + int main(int argc, char *argv[]) { @@ -272,44 +318,11 @@ main(int argc, char *argv[]) case 'T': if ((ttname = ttyname(STDIN_FILENO)) == NULL) errx(1, "stdin: not a terminal"); - goto tty; + flag = ttyname2dev(ttname, &xflg, &what); + break; case 't': - ttname = optarg; - tty: { - struct stat sb; - const char *ttypath; - char pathbuf[MAXPATHLEN]; - - flag = 0; - ttypath = NULL; - if (strcmp(ttname, "?") == 0) { -flag = KERN_PROC_TTY_NODEV; -xflg = 1; - } else if (strcmp(ttname, "-") == 0) -flag = KERN_PROC_TTY_REVOKE; - else if (strcmp(ttname, "co") == 0) -ttypath = _PATH_CONSOLE; - else if (strncmp(ttname, "pts/", 4) == 0 || -strncmp(ttname, "tty", 3) == 0) { -(void)snprintf(pathbuf, -sizeof(pathbuf), "%s%s", _PATH_DEV, ttname); -ttypath = pathbuf; - } else if (*ttname != '/') { -(void)snprintf(pathbuf, -sizeof(pathbuf), "%s%s", _PATH_TTY, ttname); -ttypath = pathbuf; - } else -ttypath = ttname; - what = KERN_PROC_TTY; - if (flag == 0) { -if (stat(ttypath, &sb) == -1) - err(1, "%s", ttypath); -if (!S_ISCHR(sb.st_mode)) - errx(1, "%s: not a terminal", ttypath); -flag = sb.st_rdev; - } + flag = ttyname2dev(optarg, &xflg, &what); break; - } case 'U': if (*optarg != '\0') { struct passwd *pw;
CVS commit: src/bin/ps
Module Name:src Committed By: wiz Date: Sun Apr 15 21:20:17 UTC 2012 Modified Files: src/bin/ps: ps.1 Log Message: Increase width of table column so it formats more nicely. To generate a diff of this commit: cvs rdiff -u -r1.99 -r1.100 src/bin/ps/ps.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.1 diff -u src/bin/ps/ps.1:1.99 src/bin/ps/ps.1:1.100 --- src/bin/ps/ps.1:1.99 Sun Apr 15 18:09:50 2012 +++ src/bin/ps/ps.1 Sun Apr 15 21:20:16 2012 @@ -1,4 +1,4 @@ -.\" $NetBSD: ps.1,v 1.99 2012/04/15 18:09:50 wiz Exp $ +.\" $NetBSD: ps.1,v 1.100 2012/04/15 21:20:16 wiz Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -77,7 +77,7 @@ controlling terminal, CPU time (includin state, and associated command. .Pp The options are as follows: -.Bl -tag -width indent +.Bl -tag -width XNXsystemXX .It Fl A Display information about all processes. This is equivalent to
CVS commit: src/bin/ps
Module Name:src Committed By: wiz Date: Sun Apr 15 18:10:13 UTC 2012 Modified Files: src/bin/ps: ps.c Log Message: Choose better argument name for `-U' (sync with man page). >From Bug Hunting in email. To generate a diff of this commit: cvs rdiff -u -r1.76 -r1.77 src/bin/ps/ps.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.c diff -u src/bin/ps/ps.c:1.76 src/bin/ps/ps.c:1.77 --- src/bin/ps/ps.c:1.76 Mon Aug 29 14:51:18 2011 +++ src/bin/ps/ps.c Sun Apr 15 18:10:13 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: ps.c,v 1.76 2011/08/29 14:51:18 joerg Exp $ */ +/* $NetBSD: ps.c,v 1.77 2012/04/15 18:10:13 wiz Exp $ */ /* * Copyright (c) 2000-2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: ps.c,v 1.76 2011/08/29 14:51:18 joerg Exp $"); +__RCSID("$NetBSD: ps.c,v 1.77 2012/04/15 18:10:13 wiz Exp $"); #endif #endif /* not lint */ @@ -761,7 +761,7 @@ usage(void) (void)fprintf(stderr, "usage:\t%s\n\t %s\n\t%s\n", "ps [-AaCcehjlmrSsTuvwx] [-k key] [-M core] [-N system] [-O fmt]", - "[-o fmt] [-p pid] [-t tty] [-U username] [-W swap]", + "[-o fmt] [-p pid] [-t tty] [-U user] [-W swap]", "ps -L"); exit(1); /* NOTREACHED */
CVS commit: src/bin/ps
Module Name:src Committed By: wiz Date: Sun Apr 15 18:09:50 UTC 2012 Modified Files: src/bin/ps: ps.1 Log Message: - choose better argument name for `-U'; - add argument names for options in man page; - improve wording, punctuation, capitalization. >From Bug Hunting in email. To generate a diff of this commit: cvs rdiff -u -r1.98 -r1.99 src/bin/ps/ps.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.1 diff -u src/bin/ps/ps.1:1.98 src/bin/ps/ps.1:1.99 --- src/bin/ps/ps.1:1.98 Thu Mar 15 15:49:59 2012 +++ src/bin/ps/ps.1 Sun Apr 15 18:09:50 2012 @@ -1,4 +1,4 @@ -.\" $NetBSD: ps.1,v 1.98 2012/03/15 15:49:59 wiz Exp $ +.\" $NetBSD: ps.1,v 1.99 2012/04/15 18:09:50 wiz Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -45,7 +45,7 @@ .Op Fl o Ar fmt .Op Fl p Ar pid .Op Fl t Ar tty -.Op Fl U Ar username +.Op Fl U Ar user .Op Fl W Ar swap .Nm .Fl L @@ -111,7 +111,7 @@ Print information associated with the fo .Ar user , pid , ppid , pgid , sess , jobc , state , tt , time , and .Ar command . -.It Fl k +.It Fl k Ar key Sort the output using the space or comma separated list of keywords. Multiple sort keys may be specified, using any of the .Fl k , Fl m , @@ -128,19 +128,19 @@ Display information associated with the .Ar tt , time , and .Ar command . -.It Fl M +.It Fl M Ar core Extract values from the specified core file instead of the running system. .It Fl m -Sort by memory usage, -equivalent to +Sort by memory usage. +This is equivalent to .Fl k Ar vsz . -.It Fl N -Extract the name list from the specified system instead of the default +.It Fl N Ar system +Extract the name list from the specified system instead of the default, .Dq Pa /netbsd . Ignored unless .Fl M is specified. -.It Fl O +.It Fl O Ar fmt Display information associated with the space or comma separated list of keywords specified. The @@ -164,7 +164,7 @@ followed by a customised header string m as described in more detail under the .Fl o option. -.It Fl o +.It Fl o Ar fmt Display information associated with the space or comma separated list of keywords specified. Use of the @@ -194,7 +194,7 @@ options. If all the keywords to be displayed have customised headers, and all the customised headers are entirely empty, then the header line is not printed at all. -.It Fl p +.It Fl p Ar pid Display information associated with the specified process .Tn ID . .It Fl r @@ -214,7 +214,7 @@ and .It Fl T Display information about processes attached to the device associated with the standard input. -.It Fl t +.It Fl t Ar tty Display information about processes attached to the specified terminal device. Use a question mark @@ -224,11 +224,9 @@ terminal device and a minus sign .Pq Dq - for processes that have been revoked from their terminal device. -.It Fl U -Displays processes belonging to the user whose username or uid has -been given to the -.Fl U -switch. +.It Fl U Ar user +Display processes belonging to the specified user, +given either as a user name or a uid. .It Fl u Display information associated with the following keywords: .Ar user , pid , %cpu , %mem , vsz , rss , tt , state , start , time , @@ -250,9 +248,8 @@ The option implies the .Fl m option. -.It Fl W -Extract swap information from the specified file instead of the -default +.It Fl W Ar swap +Extract swap information from the specified file instead of the default, .Dq Pa /dev/drum . Ignored unless .Fl M @@ -400,7 +397,7 @@ The process is being traced or debugged. .It Ar tt An abbreviation for the pathname of the controlling terminal, if any. The abbreviation consists of the two letters following -.Dq Pa /dev/tty , +.Dq Pa /dev/tty or, for the console, .Dq co . This is followed by a @@ -594,7 +591,7 @@ real group .It Ar rlink reverse link on run queue, or 0 .It Ar rlwp -Number of LWPs on a processor or run queue +number of LWPs on a processor or run queue .It Ar rss resident set size .It Ar rsz @@ -688,9 +685,9 @@ default swap device .It Pa /var/run/dev.db /dev name database .It Pa /var/db/kvm.db -system namelist database +system name list database .It Pa /netbsd -default system namelist +default system name list .El .Sh SEE ALSO .Xr kill 1 ,
CVS commit: src/bin/ps
Module Name:src Committed By: wiz Date: Thu Mar 15 15:49:59 UTC 2012 Modified Files: src/bin/ps: ps.1 Log Message: Remove trailing whitespace. To generate a diff of this commit: cvs rdiff -u -r1.97 -r1.98 src/bin/ps/ps.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.1 diff -u src/bin/ps/ps.1:1.97 src/bin/ps/ps.1:1.98 --- src/bin/ps/ps.1:1.97 Thu Mar 15 15:43:43 2012 +++ src/bin/ps/ps.1 Thu Mar 15 15:49:59 2012 @@ -1,4 +1,4 @@ -.\" $NetBSD: ps.1,v 1.97 2012/03/15 15:43:43 christos Exp $ +.\" $NetBSD: ps.1,v 1.98 2012/03/15 15:49:59 wiz Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -352,7 +352,7 @@ Marks a process running on a processor. .It R Marks a runnable process, or one that is in the process of creation. .It S -Marks a process that is sleeping interruptibly for less than about +Marks a process that is sleeping interruptibly for less than about .Dv MAXSLP (default 20) seconds. .It T
CVS commit: src/bin/ps
Module Name:src Committed By: christos Date: Thu Mar 15 15:43:43 UTC 2012 Modified Files: src/bin/ps: ps.1 Log Message: Fix obsolete example (that referred to letters in process state that are not set anymore), and clarify their meaning. To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/bin/ps/ps.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.1 diff -u src/bin/ps/ps.1:1.96 src/bin/ps/ps.1:1.97 --- src/bin/ps/ps.1:1.96 Thu Feb 23 16:54:28 2012 +++ src/bin/ps/ps.1 Thu Mar 15 11:43:43 2012 @@ -1,4 +1,4 @@ -.\" $NetBSD: ps.1,v 1.96 2012/02/23 21:54:28 dholland Exp $ +.\" $NetBSD: ps.1,v 1.97 2012/03/15 15:43:43 christos Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)ps.1 8.3 (Berkeley) 4/18/94 .\" -.Dd February 23, 2012 +.Dd March 15, 2012 .Dt PS 1 .Os .Sh NAME @@ -337,26 +337,30 @@ Otherwise, the start time is displayed u format. .It Ar state The state is given by a sequence of letters, for example, -.Dq Tn RWNA . +.Dq Tn RNs . The first letter indicates the run state of the process: .Pp .Bl -tag -width indent -compact .It D -Marks a process in disk (or other short term, uninterruptible) wait. +Marks a process in device or other short term, uninterruptible wait. .It I -Marks a process that is idle (sleeping for longer than about 20 seconds). +Marks a process that is idle (sleeping interruptibly for longer than about +.Dv MAXSLP +(default 20) seconds). .It O Marks a process running on a processor. .It R Marks a runnable process, or one that is in the process of creation. .It S -Marks a process that is sleeping for less than about 20 seconds. +Marks a process that is sleeping interruptibly for less than about +.Dv MAXSLP +(default 20) seconds. .It T Marks a stopped process. .It U Marks a suspended process. .It Z -Marks a dead process (a +Marks a dead process that has exited, but not been waited for (a .Dq zombie ) . .El .Pp @@ -373,17 +377,17 @@ The process has raised .Tn CPU scheduling priority. .It a -The process is using scheduler activations. +The process is using scheduler activations (deprecated). .It E -The process is trying to exit. +The process is in the process of exiting. .It K The process is a kernel thread or system process. .It l The process has multiple LWPs. .It N -The process has reduced +The process is niced (has reduced .Tn CPU -scheduling priority (see +scheduling priority) (see .Xr setpriority 2 ) . .It s The process is a session leader.
CVS commit: src/bin/ps
Module Name:src Committed By: dholland Date: Thu Feb 23 21:54:28 UTC 2012 Modified Files: src/bin/ps: ps.1 Log Message: The 'lstart' column uses strftime %c, not %C. Noted by mrg. To generate a diff of this commit: cvs rdiff -u -r1.95 -r1.96 src/bin/ps/ps.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.1 diff -u src/bin/ps/ps.1:1.95 src/bin/ps/ps.1:1.96 --- src/bin/ps/ps.1:1.95 Fri Jan 27 05:59:17 2012 +++ src/bin/ps/ps.1 Thu Feb 23 21:54:28 2012 @@ -1,4 +1,4 @@ -.\" $NetBSD: ps.1,v 1.95 2012/01/27 05:59:17 dholland Exp $ +.\" $NetBSD: ps.1,v 1.96 2012/02/23 21:54:28 dholland Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)ps.1 8.3 (Berkeley) 4/18/94 .\" -.Dd October 22, 2009 +.Dd February 23, 2012 .Dt PS 1 .Os .Sh NAME @@ -313,7 +313,7 @@ The soft limit on memory used, specified .Xr setrlimit 2 . .It Ar lstart The exact time the command started, using the -.Dq \&%C +.Dq \&%c format described in .Xr strftime 3 . .It Ar nice
CVS commit: src/bin/ps
Module Name:src Committed By: wiz Date: Mon Feb 13 12:55:28 UTC 2012 Modified Files: src/bin/ps: print.c Log Message: Remove unused variable. >From cppcheck via Henning Petersen in PR 46002. To generate a diff of this commit: cvs rdiff -u -r1.118 -r1.119 src/bin/ps/print.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/print.c diff -u src/bin/ps/print.c:1.118 src/bin/ps/print.c:1.119 --- src/bin/ps/print.c:1.118 Mon Jun 13 03:42:15 2011 +++ src/bin/ps/print.c Mon Feb 13 12:55:28 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.118 2011/06/13 03:42:15 dholland Exp $ */ +/* $NetBSD: print.c,v 1.119 2012/02/13 12:55:28 wiz Exp $ */ /* * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: print.c,v 1.118 2011/06/13 03:42:15 dholland Exp $"); +__RCSID("$NetBSD: print.c,v 1.119 2012/02/13 12:55:28 wiz Exp $"); #endif #endif /* not lint */ @@ -554,13 +554,12 @@ void lstate(void *arg, VARENT *ve, int mode) { struct kinfo_lwp *k; - int flag, is_zombie; + int flag; char *cp; VAR *v; char buf[16]; k = arg; - is_zombie = 0; v = ve->var; flag = k->l_flag; cp = buf; @@ -590,7 +589,6 @@ lstate(void *arg, VARENT *ve, int mode) case LSZOMB: case LSDEAD: *cp = 'Z'; - is_zombie = 1; break; case LSSUSPENDED:
CVS commit: src/bin/ps
Module Name:src Committed By: dholland Date: Fri Jan 27 05:59:18 UTC 2012 Modified Files: src/bin/ps: ps.1 Log Message: Minor English improvements for -w, partly from Snader_LB. To generate a diff of this commit: cvs rdiff -u -r1.94 -r1.95 src/bin/ps/ps.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.1 diff -u src/bin/ps/ps.1:1.94 src/bin/ps/ps.1:1.95 --- src/bin/ps/ps.1:1.94 Sun Feb 13 08:34:00 2011 +++ src/bin/ps/ps.1 Fri Jan 27 05:59:17 2012 @@ -1,4 +1,4 @@ -.\" $NetBSD: ps.1,v 1.94 2011/02/13 08:34:00 dholland Exp $ +.\" $NetBSD: ps.1,v 1.95 2012/01/27 05:59:17 dholland Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -258,13 +258,13 @@ Ignored unless .Fl M is specified. .It Fl w -Use 132 columns to display information, instead of the default which +Use 132 columns to display information instead of the default, which is your window size. If the .Fl w option is specified more than once, .Nm -will use as many columns as necessary without regard for your window size. +will use as many columns as necessary without regard to your window size. .It Fl x Also display information about processes without controlling terminals. .El
CVS commit: src/bin/ps
Module Name:src Committed By: dholland Date: Mon Jun 13 03:42:15 UTC 2011 Modified Files: src/bin/ps: print.c Log Message: When converting from pages to kilobytes, cast the return value of getpagesize() to size_t. For some reason getpagesize() is defined to return int, and several of the page counts we get come back from the kernel as int32_t; in LP64 without the cast the byte count will be computed in a 32-bit value and for large processes will overflow and become negative... and then remain negative when divided by 1024 to convert to kilobytes. Fixes a problem I hit the other day where I saw negative RSS, which turns out also to be PR 40642. Note: other logic in here will break down when we first get >2TB processes... and int32 page counts will break on >8TB processes. But hopefully we won't see any of that for a few years yet. To generate a diff of this commit: cvs rdiff -u -r1.117 -r1.118 src/bin/ps/print.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/print.c diff -u src/bin/ps/print.c:1.117 src/bin/ps/print.c:1.118 --- src/bin/ps/print.c:1.117 Sat Jan 22 21:09:51 2011 +++ src/bin/ps/print.c Mon Jun 13 03:42:15 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.117 2011/01/22 21:09:51 christos Exp $ */ +/* $NetBSD: print.c,v 1.118 2011/06/13 03:42:15 dholland Exp $ */ /* * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: print.c,v 1.117 2011/01/22 21:09:51 christos Exp $"); +__RCSID("$NetBSD: print.c,v 1.118 2011/06/13 03:42:15 dholland Exp $"); #endif #endif /* not lint */ @@ -967,7 +967,7 @@ } } -#define pgtok(a)(((a)*getpagesize())/1024) +#define pgtok(a)(((a)*(size_t)getpagesize())/1024) void vsize(void *arg, VARENT *ve, int mode)
CVS commit: src/bin/ps
Module Name:src Committed By: dholland Date: Sun Feb 13 08:34:01 UTC 2011 Modified Files: src/bin/ps: ps.1 Log Message: fix typo, from Randolf Richardson in PR 44559 To generate a diff of this commit: cvs rdiff -u -r1.93 -r1.94 src/bin/ps/ps.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.1 diff -u src/bin/ps/ps.1:1.93 src/bin/ps/ps.1:1.94 --- src/bin/ps/ps.1:1.93 Fri May 14 17:37:06 2010 +++ src/bin/ps/ps.1 Sun Feb 13 08:34:00 2011 @@ -1,4 +1,4 @@ -.\" $NetBSD: ps.1,v 1.93 2010/05/14 17:37:06 joerg Exp $ +.\" $NetBSD: ps.1,v 1.94 2011/02/13 08:34:00 dholland Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -217,7 +217,7 @@ .It Fl t Display information about processes attached to the specified terminal device. -Use an question mark +Use a question mark .Pq Dq \&? for processes not attached to a terminal device and a minus sign
CVS commit: src/bin/ps
Module Name:src Committed By: christos Date: Sat Jan 22 21:09:52 UTC 2011 Modified Files: src/bin/ps: print.c Log Message: fix previous. To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/bin/ps/print.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/print.c diff -u src/bin/ps/print.c:1.116 src/bin/ps/print.c:1.117 --- src/bin/ps/print.c:1.116 Sat Jan 22 15:55:58 2011 +++ src/bin/ps/print.c Sat Jan 22 16:09:51 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.116 2011/01/22 20:55:58 christos Exp $ */ +/* $NetBSD: print.c,v 1.117 2011/01/22 21:09:51 christos Exp $ */ /* * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: print.c,v 1.116 2011/01/22 20:55:58 christos Exp $"); +__RCSID("$NetBSD: print.c,v 1.117 2011/01/22 21:09:51 christos Exp $"); #endif #endif /* not lint */ @@ -580,10 +580,13 @@ case LSRUN: case LSIDL: - case LSONPROC: *cp = 'R'; break; + case LSONPROC: + *cp = 'O'; + break; + case LSZOMB: case LSDEAD: *cp = 'Z'; @@ -598,8 +601,10 @@ *cp = '?'; } cp++; - if (flag & P_SYSTEM) + if (flag & L_SYSTEM) *cp++ = 'K'; + if (flag & L_SA) + *cp++ = 'a'; if (flag & L_DETACHED) *cp++ = '-'; *cp = '\0';
CVS commit: src/bin/ps
Module Name:src Committed By: christos Date: Sat Jan 22 20:55:58 UTC 2011 Modified Files: src/bin/ps: print.c Log Message: Make printing of lwp flags similar to the process one, identifying (O)nproc (K)ernel threads and scheduler (a)ctivations. To generate a diff of this commit: cvs rdiff -u -r1.115 -r1.116 src/bin/ps/print.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/print.c diff -u src/bin/ps/print.c:1.115 src/bin/ps/print.c:1.116 --- src/bin/ps/print.c:1.115 Wed Jul 28 13:39:54 2010 +++ src/bin/ps/print.c Sat Jan 22 15:55:58 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.115 2010/07/28 17:39:54 njoly Exp $ */ +/* $NetBSD: print.c,v 1.116 2011/01/22 20:55:58 christos Exp $ */ /* * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: print.c,v 1.115 2010/07/28 17:39:54 njoly Exp $"); +__RCSID("$NetBSD: print.c,v 1.116 2011/01/22 20:55:58 christos Exp $"); #endif #endif /* not lint */ @@ -598,6 +598,8 @@ *cp = '?'; } cp++; + if (flag & P_SYSTEM) + *cp++ = 'K'; if (flag & L_DETACHED) *cp++ = '-'; *cp = '\0';
CVS commit: src/bin/ps
Module Name:src Committed By: njoly Date: Wed Jul 28 17:39:54 UTC 2010 Modified Files: src/bin/ps: print.c Log Message: Do not check pcpu value against 100.0 but rather 99.95, to properly deal with value rounding. From a...@. To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 src/bin/ps/print.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/print.c diff -u src/bin/ps/print.c:1.114 src/bin/ps/print.c:1.115 --- src/bin/ps/print.c:1.114 Tue Jul 27 12:40:48 2010 +++ src/bin/ps/print.c Wed Jul 28 17:39:54 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.114 2010/07/27 12:40:48 njoly Exp $ */ +/* $NetBSD: print.c,v 1.115 2010/07/28 17:39:54 njoly Exp $ */ /* * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: print.c,v 1.114 2010/07/27 12:40:48 njoly Exp $"); +__RCSID("$NetBSD: print.c,v 1.115 2010/07/28 17:39:54 njoly Exp $"); #endif #endif /* not lint */ @@ -1092,7 +1092,7 @@ k = arg; v = ve->var; dbl = getpcpu(k); - doubleprintorsetwidth(v, dbl, (dbl >= 100.0) ? 0 : 1, mode); + doubleprintorsetwidth(v, dbl, (dbl >= 99.95) ? 0 : 1, mode); } double
CVS commit: src/bin/ps
Module Name:src Committed By: njoly Date: Tue Jul 27 12:40:49 UTC 2010 Modified Files: src/bin/ps: print.c Log Message: Make %cpu drop the decimal part when reaching 100%, to stay in the 5 expected columns. To generate a diff of this commit: cvs rdiff -u -r1.113 -r1.114 src/bin/ps/print.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/print.c diff -u src/bin/ps/print.c:1.113 src/bin/ps/print.c:1.114 --- src/bin/ps/print.c:1.113 Mon May 31 03:18:33 2010 +++ src/bin/ps/print.c Tue Jul 27 12:40:48 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.113 2010/05/31 03:18:33 rmind Exp $ */ +/* $NetBSD: print.c,v 1.114 2010/07/27 12:40:48 njoly Exp $ */ /* * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: print.c,v 1.113 2010/05/31 03:18:33 rmind Exp $"); +__RCSID("$NetBSD: print.c,v 1.114 2010/07/27 12:40:48 njoly Exp $"); #endif #endif /* not lint */ @@ -1087,10 +1087,12 @@ { struct kinfo_proc2 *k; VAR *v; + double dbl; k = arg; v = ve->var; - doubleprintorsetwidth(v, getpcpu(k), 1, mode); + dbl = getpcpu(k); + doubleprintorsetwidth(v, dbl, (dbl >= 100.0) ? 0 : 1, mode); } double
CVS commit: src/bin/ps
Module Name:src Committed By: joerg Date: Fri May 14 17:37:06 UTC 2010 Modified Files: src/bin/ps: ps.1 Log Message: Don't break lines in .It, there be dragons in groff. To generate a diff of this commit: cvs rdiff -u -r1.92 -r1.93 src/bin/ps/ps.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.1 diff -u src/bin/ps/ps.1:1.92 src/bin/ps/ps.1:1.93 --- src/bin/ps/ps.1:1.92 Mon Mar 22 18:35:09 2010 +++ src/bin/ps/ps.1 Fri May 14 17:37:06 2010 @@ -1,4 +1,4 @@ -.\" $NetBSD: ps.1,v 1.92 2010/03/22 18:35:09 joerg Exp $ +.\" $NetBSD: ps.1,v 1.93 2010/05/14 17:37:06 joerg Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -288,9 +288,7 @@ .Bl -column P_NOCLDSTOP P_NOCLDSTOP compact .It Dv "P_ADVLOCK" Ta No "0x0001 process may hold a POSIX advisory lock" .It Dv "P_CONTROLT" Ta No "0x0002 process has a controlling terminal" -.It Dv "P_NOCLDSTOP" Ta No "0x0008 no -.Dv SIGCHLD -when children stop +.It Dv "P_NOCLDSTOP" Ta No "0x0008 no" Dv SIGCHLD No when children stop .It Dv "P_PPWAIT" Ta No "0x0010 parent is waiting for child to exec/exit" .It Dv "P_PROFIL" Ta No "0x0020 process has started profiling" .It Dv "P_SELECT" Ta No "0x0040 selecting; wakeup/waiting danger" @@ -301,8 +299,7 @@ .It Dv "P_TRACED" Ta No "0x0800 process is being traced" .It Dv "P_WAITED" Ta No "0x1000 debugging process has waited for child" .It Dv "P_WEXIT" Ta No "0x2000 working on exiting" -.It Dv "P_EXEC" Ta No "0x4000 process called" -.Xr execve 2 +.It Dv "P_EXEC" Ta No "0x4000 process called" Xr execve 2 .It Dv "P_OWEUPC" Ta No "0x8000 owe process an addupc() call at next ast" .\" the routine addupc is not documented in the man pages .It Dv "P_FSTRACE" Ta No "0x0001 tracing via file system"
CVS commit: src/bin/ps
Module Name:src Committed By: joerg Date: Mon Mar 22 18:35:09 UTC 2010 Modified Files: src/bin/ps: ps.1 Log Message: Use .In instead of .Aq Pa for header files To generate a diff of this commit: cvs rdiff -u -r1.91 -r1.92 src/bin/ps/ps.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.1 diff -u src/bin/ps/ps.1:1.91 src/bin/ps/ps.1:1.92 --- src/bin/ps/ps.1:1.91 Wed Oct 21 22:18:37 2009 +++ src/bin/ps/ps.1 Mon Mar 22 18:35:09 2010 @@ -1,4 +1,4 @@ -.\" $NetBSD: ps.1,v 1.91 2009/10/21 22:18:37 wiz Exp $ +.\" $NetBSD: ps.1,v 1.92 2010/03/22 18:35:09 joerg Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -284,7 +284,7 @@ .It Ar flags The flags (in hexadecimal) associated with the process as in the include file -.Aq Pa sys/proc.h : +.In sys/proc.h : .Bl -column P_NOCLDSTOP P_NOCLDSTOP compact .It Dv "P_ADVLOCK" Ta No "0x0001 process may hold a POSIX advisory lock" .It Dv "P_CONTROLT" Ta No "0x0002 process has a controlling terminal"
CVS commit: src/bin/ps
Module Name:src Committed By: wiz Date: Mon Aug 3 22:22:10 UTC 2009 Modified Files: src/bin/ps: ps.1 Log Message: Bump date for previous. To generate a diff of this commit: cvs rdiff -u -r1.88 -r1.89 src/bin/ps/ps.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.1 diff -u src/bin/ps/ps.1:1.88 src/bin/ps/ps.1:1.89 --- src/bin/ps/ps.1:1.88 Mon Aug 3 20:00:39 2009 +++ src/bin/ps/ps.1 Mon Aug 3 22:22:10 2009 @@ -1,4 +1,4 @@ -.\" $NetBSD: ps.1,v 1.88 2009/08/03 20:00:39 dsl Exp $ +.\" $NetBSD: ps.1,v 1.89 2009/08/03 22:22:10 wiz Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)ps.1 8.3 (Berkeley) 4/18/94 .\" -.Dd October 18, 2008 +.Dd August 4, 2009 .Dt PS 1 .Os .Sh NAME
CVS commit: src/bin/ps
Module Name:src Committed By: dsl Date: Mon Aug 3 20:00:39 UTC 2009 Modified Files: src/bin/ps: ps.1 Log Message: Remove reference to P_SYSTRACE. Fixes PR/41426 (leave defn in sys/sysctl.h since the bit shouldn't be reused!) To generate a diff of this commit: cvs rdiff -u -r1.87 -r1.88 src/bin/ps/ps.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.1 diff -u src/bin/ps/ps.1:1.87 src/bin/ps/ps.1:1.88 --- src/bin/ps/ps.1:1.87 Fri Mar 13 11:13:46 2009 +++ src/bin/ps/ps.1 Mon Aug 3 20:00:39 2009 @@ -1,4 +1,4 @@ -.\" $NetBSD: ps.1,v 1.87 2009/03/13 11:13:46 joerg Exp $ +.\" $NetBSD: ps.1,v 1.88 2009/08/03 20:00:39 dsl Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -311,7 +311,6 @@ .It Dv "P_32" Ta No "0x0004 32-bit process (used on 64-bit kernels)" .It Dv "P_BIGLOCK" Ta No "0x0008 process needs kernel ``big lock'' to run" .It Dv "P_INEXEC" Ta No "0x0010 process is exec'ing and cannot be traced" -.It Dv "P_SYSTRACE" Ta No "0x0020 process system call tracing active" .El .It Ar lim The soft limit on memory used, specified via a call to