SCCS-vsn: bin/ps/keyword.c 5.8
SCCS-vsn: bin/ps/nlist.c 5.2
SCCS-vsn: bin/ps/print.c 5.7
SCCS-vsn: bin/ps/ps.c 5.41
SCCS-vsn: bin/ps/ps.h 5.3
-static char sccsid[] = "@(#)keyword.c 5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)keyword.c 5.8 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
#include <sys/proc.h>
#include <errno.h>
#include <stdio.h>
#include <sys/proc.h>
#include <errno.h>
#include <stdio.h>
#include <stddef.h>
#include <string.h>
#include "ps.h"
#include <stddef.h>
#include <string.h>
#include "ps.h"
/* void */;
if (!(v = findvar(cp)))
continue;
/* void */;
if (!(v = findvar(cp)))
continue;
- if ((vent = (struct varent *)malloc(sizeof(struct varent))) ==
- NULL) {
- (void)fprintf(stderr, "ps: no space\n");
- exit(1);
- }
+ if ((vent = malloc(sizeof(struct varent))) == NULL)
+ err("%s", strerror(errno));
vent->var = v;
vent->next = NULL;
if (vhead == NULL)
vent->var = v;
vent->next = NULL;
if (vhead == NULL)
- if (!vhead) {
- (void)fprintf(stderr, "ps: no valid keywords\n");
- exit(1);
- }
+ if (!vhead)
+ err("no valid keywords\n");
-static char sccsid[] = "@(#)nlist.c 5.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)nlist.c 5.2 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#include <nlist.h>
#include <errno.h>
#include <stdio.h>
#endif /* not lint */
#include <sys/types.h>
#include <nlist.h>
#include <errno.h>
#include <stdio.h>
struct nlist psnl[] = {
{"_ecmx"},
struct nlist psnl[] = {
{"_ecmx"},
-static char sccsid[] = "@(#)print.c 5.6 (Berkeley) %G%";
+static char sccsid[] = "@(#)print.c 5.7 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
(void) printf(ofmt, v->width, *(u_long *)bp &~ KERNBASE);
break;
default:
(void) printf(ofmt, v->width, *(u_long *)bp &~ KERNBASE);
break;
default:
- error("unknown type %d", v->type);
+ err("unknown type %d", v->type);
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)ps.c 5.40 (Berkeley) %G%";
+static char sccsid[] = "@(#)ps.c 5.41 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
#include <kvm.h>
#include <errno.h>
#include <unistd.h>
#include <kvm.h>
#include <errno.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
break;
case 'T':
if ((optarg = ttyname(STDIN_FILENO)) == NULL)
break;
case 'T':
if ((optarg = ttyname(STDIN_FILENO)) == NULL)
- error("stdin: not a terminal");
+ err("stdin: not a terminal");
/* FALLTHROUGH */
case 't': {
char *ttypath;
/* FALLTHROUGH */
case 't': {
char *ttypath;
_PATH_TTY, optarg);
else
ttypath = optarg;
_PATH_TTY, optarg);
else
ttypath = optarg;
- if (stat(ttypath, &stbuf) == -1) {
- (void)fprintf(stderr,
- "ps: %s: %s\n", ttypath, strerror(errno));
- exit(1);
- }
+ if (stat(ttypath, &stbuf) == -1)
+ err("%s: %s", ttypath, strerror(errno));
if (!S_ISCHR(stbuf.st_mode))
if (!S_ISCHR(stbuf.st_mode))
- error("%s: not a terminal", ttypath);
+ err("%s: not a terminal", ttypath);
ttydev = stbuf.st_rdev;
break;
}
ttydev = stbuf.st_rdev;
break;
}
}
#endif
if (kvm_openfiles(nlistf, memf, swapf) == -1)
}
#endif
if (kvm_openfiles(nlistf, memf, swapf) == -1)
- error("kvm_openfiles: %s", kvm_geterr());
+ err("kvm_openfiles: %s", kvm_geterr());
if (!fmt)
parsefmt(dfmt);
if (!fmt)
parsefmt(dfmt);
- if ((nentries = kvm_getprocs(what, flag)) == -1) {
- (void) fprintf(stderr, "ps: %s\n", kvm_geterr());
- exit(1);
- }
- kinfo = (KINFO *)malloc(nentries * sizeof(KINFO));
- if (kinfo == NULL) {
- (void)fprintf(stderr, "ps: %s\n", strerror(ENOMEM));
- exit(1);
- }
+ if ((nentries = kvm_getprocs(what, flag)) == -1)
+ err("%s", kvm_geterr());
+ kinfo = malloc(nentries * sizeof(KINFO));
+ if (kinfo == NULL)
+ err("%s", strerror(errno));
for (nentries = 0; p = kvm_nextproc(); ++nentries) {
kinfo[nentries].ki_p = p;
kinfo[nentries].ki_e = kvm_geteproc(p);
for (nentries = 0; p = kvm_nextproc(); ++nentries) {
kinfo[nentries].ki_p = p;
kinfo[nentries].ki_e = kvm_geteproc(p);
register struct usave *usp;
register struct user *up;
register struct usave *usp;
register struct user *up;
- if ((usp = (struct usave *)calloc(1, sizeof(struct usave))) == NULL) {
- (void)fprintf(stderr, "ps: %s\n", strerror(errno));
- exit(1);
- }
+ if ((usp = calloc(1, sizeof(struct usave))) == NULL)
+ err("%s", strerror(errno));
ki->ki_u = usp;
up = kvm_getu(ki->ki_p);
/*
ki->ki_u = usp;
up = kvm_getu(ki->ki_p);
/*
char *newopts, *ns, *cp;
len = strlen(s);
char *newopts, *ns, *cp;
len = strlen(s);
- if ((newopts = ns = malloc(len + 2)) == NULL) {
- (void)fprintf(stderr, "ps: %s\n", strerror(errno));
- exit(1);
- }
+ if ((newopts = ns = malloc(len + 2)) == NULL)
+ err("%s", strerror(errno));
/*
* options begin with '-'
*/
/*
* options begin with '-'
*/
-#ifdef lint
-/* VARARGS1 */
-error(fmt) char *fmt; { (void) fputs(fmt, stderr); exit(1); /* NOTREACHED */ }
+#if __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+
+void
+#if __STDC__
+err(const char *fmt, ...)
- (void) fprintf(stderr, "ps: ");
- (void) vfprintf(stderr, fmt, ap);
- (void) fprintf(stderr, "\n");
+#else
+ va_start(ap);
+#endif
+ (void)fprintf(stderr, "ps: ");
+ (void)vfprintf(stderr, fmt, ap);
+ (void)fprintf(stderr, "\n");
usage()
{
(void) fprintf(stderr,
usage()
{
(void) fprintf(stderr,
- "usage:\tps [ -aChjlmrSsTuvwx ] [ -O|o fmt ] [ -p pid ] [ -t tty ] [ system ] [ core ] [ swap ]\n\t ps [ -L ]\n");
+"usage: ps [-aChjlmrSTuvwx] [-O|o fmt] [-p pid] [-t tty]\n\t [-M core] [-N system] [-W swap]\n ps [-L]\n");
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)ps.h 5.2 (Berkeley) %G%
+ * @(#)ps.h 5.3 (Berkeley) %G%
*/
#define UNLIMITED 0 /* unlimited terminal width */
*/
#define UNLIMITED 0 /* unlimited terminal width */
-extern VAR var[];
-extern struct varent *vhead, *vtail;