/*-
- * Copyright (c) 1990, 1993
+ * Copyright (c) 1990, 1993, 1994
* The Regents of the University of California. All rights reserved.
*
- * %sccs.include.redist.c%
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
*/
#ifndef lint
static char copyright[] =
-"@(#) Copyright (c) 1990, 1993\n\
+"@(#) Copyright (c) 1990, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)ps.c 8.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94";
#endif /* not lint */
#include <sys/param.h>
int argc;
char *argv[];
{
- register struct kinfo_proc *kp;
- register struct varent *vent;
- int nentries;
- register int i;
+ struct kinfo_proc *kp;
+ struct varent *vent;
struct winsize ws;
dev_t ttydev;
- int all, ch, flag, fmt, lineno, pid, prtheader, uid, wflag, what, xflg;
+ pid_t pid;
+ uid_t uid;
+ int all, ch, flag, i, fmt, lineno, nentries;
+ int prtheader, wflag, what, xflg;
char *nlistf, *memf, *swapf, errbuf[256];
if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, (char *)&ws) == -1 &&
argv[1] = kludge_oldps_options(argv[1]);
all = fmt = prtheader = wflag = xflg = 0;
- pid = uid = -1;
+ pid = -1;
+ uid = (uid_t) -1;
ttydev = NODEV;
memf = nlistf = swapf = NULL;
while ((ch = getopt(argc, argv,
fmt = 1;
break;
case 'p':
- pid = atoi(optarg);
+ pid = atol(optarg);
xflg = 1;
break;
case 'r':
/*
* get proc list
*/
- if (uid != -1) {
+ if (uid != (uid_t) -1) {
what = KERN_PROC_UID;
flag = uid;
} else if (ttydev != NODEV) {
} else if (pid != -1) {
what = KERN_PROC_PID;
flag = pid;
+ } else {
+ what = KERN_PROC_ALL;
+ flag = 0;
+ }
/*
* select procs
*/
static void
scanvars()
{
- register struct varent *vent;
- register VAR *v;
- register int i;
+ struct varent *vent;
+ VAR *v;
+ int i;
for (vent = vhead; vent; vent = vent->next) {
v = vent->var;
char *comm;
int maxlen;
{
- register char *s;
+ char *s;
if ((s =
fmt_argv((*fn)(kd, ki->ki_p, termwidth), comm, maxlen)) == NULL)
saveuser(ki)
KINFO *ki;
{
- register struct usave *usp = &ki->ki_u;
struct pstats pstats;
- extern char *fmt_argv();
+ struct usave *usp;
+ usp = &ki->ki_u;
if (kvm_read(kd, (u_long)&KI_PROC(ki)->p_addr->u_stats,
- (char *)&pstats, sizeof(pstats)) == sizeof(pstats)) {
+ (char *)&pstats, sizeof(pstats)) == sizeof(pstats)) {
/*
* The u-area might be swapped out, and we can't get
* at it because we have a crashdump and no swap.
static void
usage()
{
+
(void)fprintf(stderr,
-"usage: ps [-aChjlmrSTuvwx] [-O|o fmt] [-p pid] [-t tty]\n\t [-M core] [-N system] [-W swap]\n ps [-L]\n");
+ "usage:\t%s\n\t %s\n\t%s\n",
+ "ps [-aChjlmrSTuvwx] [-O|o fmt] [-p pid] [-t tty]",
+ "[-M core] [-N system] [-W swap]",
+ "ps [-L]");
exit(1);
}