diff options
-rw-r--r-- | bin/ps/print.c | 20 | ||||
-rw-r--r-- | bin/ps/ps.1 | 5 | ||||
-rw-r--r-- | bin/ps/ps.c | 12 |
3 files changed, 30 insertions, 7 deletions
diff --git a/bin/ps/print.c b/bin/ps/print.c index cf63c65200a..7fc55cc570a 100644 --- a/bin/ps/print.c +++ b/bin/ps/print.c @@ -1,4 +1,4 @@ -/* $OpenBSD: print.c,v 1.34 2004/11/18 15:10:24 markus Exp $ */ +/* $OpenBSD: print.c,v 1.35 2004/11/24 19:17:10 deraadt Exp $ */ /* $NetBSD: print.c,v 1.27 1995/09/29 21:58:12 cgd Exp $ */ /*- @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -static char rcsid[] = "$OpenBSD: print.c,v 1.34 2004/11/18 15:10:24 markus Exp $"; +static char rcsid[] = "$OpenBSD: print.c,v 1.35 2004/11/24 19:17:10 deraadt Exp $"; #endif #endif /* not lint */ @@ -182,8 +182,9 @@ logname(const struct kinfo_proc2 *kp, VARENT *ve) void state(const struct kinfo_proc2 *kp, VARENT *ve) { + extern int ncpu; int flag; - char *cp; + char *cp, state = '\0'; VAR *v; char buf[16]; @@ -207,7 +208,7 @@ state(const struct kinfo_proc2 *kp, VARENT *ve) case SRUN: case SIDL: case SONPROC: - *cp = 'R'; + state = *cp = 'R'; break; case SZOMB: @@ -218,6 +219,7 @@ state(const struct kinfo_proc2 *kp, VARENT *ve) *cp = '?'; } cp++; + if (flag & P_INMEM) { } else *cp++ = 'W'; @@ -246,6 +248,16 @@ state(const struct kinfo_proc2 *kp, VARENT *ve) if ((flag & P_CONTROLT) && kp->p__pgid == kp->p_tpgid) *cp++ = '+'; *cp = '\0'; + + if (state == 'R' && ncpu && kp->p_cpuid != KI_NOCPU) { + char pbuf[16]; + + snprintf(pbuf, sizeof pbuf, "/%d", kp->p_cpuid); + *++cp = '\0'; + strlcat(buf, pbuf, sizeof buf); + cp = buf + strlen(buf); + } + (void)printf("%-*s", v->width, buf); } diff --git a/bin/ps/ps.1 b/bin/ps/ps.1 index 4437576cbbc..124f4f6c38a 100644 --- a/bin/ps/ps.1 +++ b/bin/ps/ps.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ps.1,v 1.50 2004/06/20 01:42:44 aaron Exp $ +.\" $OpenBSD: ps.1,v 1.51 2004/11/24 19:17:10 deraadt Exp $ .\" $NetBSD: ps.1,v 1.16 1996/03/21 01:36:28 jtc Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 @@ -332,6 +332,9 @@ The process is being traced or debugged. .It x The process is being monitored by .Xr systrace 1 . +.It / Ns Ar n +On multiprocessor machines, specifies processor number +.Ar n . .El .It tt An abbreviation for the pathname of the controlling terminal, if any. diff --git a/bin/ps/ps.c b/bin/ps/ps.c index 66089153613..435983d6eb1 100644 --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ps.c,v 1.39 2004/09/14 23:45:35 deraadt Exp $ */ +/* $OpenBSD: ps.c,v 1.40 2004/11/24 19:17:10 deraadt Exp $ */ /* $NetBSD: ps.c,v 1.15 1995/05/18 20:33:25 mycroft Exp $ */ /*- @@ -40,7 +40,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -static char rcsid[] = "$OpenBSD: ps.c,v 1.39 2004/09/14 23:45:35 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: ps.c,v 1.40 2004/11/24 19:17:10 deraadt Exp $"; #endif #endif /* not lint */ @@ -80,6 +80,8 @@ int sumrusage; /* -S */ int termwidth; /* width of screen (0 == infinity) */ int totwidth; /* calculated width of requested variables */ +int ncpu = 1; + int needcomm, needenv, commandonly; enum sort { DEFAULT, SORTMEM, SORTCPU } sortby = DEFAULT; @@ -312,6 +314,12 @@ main(int argc, char *argv[]) what = KERN_PROC_ALL; flag = 0; } + + mib[0] = CTL_HW; + mib[1] = HW_NCPU; + size = sizeof(ncpu); + (void) sysctl(mib, 2, &ncpu, &size, NULL, 0); + /* * select procs */ |