Use tty "?" to select processes with no controlling tty and tty "-" to

select processes with a revoked controlling tty.

Idea from SunOS/Solaris, suggested by Alexis Rosen.
This commit is contained in:
simonb 2000-04-15 04:40:46 +00:00
parent e465cebbfc
commit 8384a1bbb8
2 changed files with 19 additions and 10 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: ps.1,v 1.35 2000/04/10 06:37:37 chs Exp $ .\" $NetBSD: ps.1,v 1.36 2000/04/15 04:40:46 simonb Exp $
.\" .\"
.\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" Copyright (c) 1980, 1990, 1991, 1993, 1994
.\" The Regents of the University of California. All rights reserved. .\" The Regents of the University of California. All rights reserved.
@ -165,7 +165,9 @@ Display information about processes attached to the device associated
with the standard input. with the standard input.
.It Fl t .It Fl t
Display information about processes attached to the specified terminal Display information about processes attached to the specified terminal
device. device. Use an question mark (``?'') for processes not attached to a
terminal device and a minus sign (``-'') for processes that have
been revoked from their terminal device.
.It Fl U .It Fl U
Displays processes belonging to the user whose username or uid has Displays processes belonging to the user whose username or uid has
been given to the been given to the

View File

@ -1,4 +1,4 @@
/* $NetBSD: ps.c,v 1.35 2000/04/10 06:37:37 chs Exp $ */ /* $NetBSD: ps.c,v 1.36 2000/04/15 04:40:46 simonb Exp $ */
/*- /*-
* Copyright (c) 1990, 1993, 1994 * Copyright (c) 1990, 1993, 1994
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 1993, 1994\n\
#if 0 #if 0
static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94";
#else #else
__RCSID("$NetBSD: ps.c,v 1.35 2000/04/10 06:37:37 chs Exp $"); __RCSID("$NetBSD: ps.c,v 1.36 2000/04/15 04:40:46 simonb Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -218,19 +218,26 @@ main(argc, argv)
struct stat sb; struct stat sb;
char *ttypath, pathbuf[MAXPATHLEN]; char *ttypath, pathbuf[MAXPATHLEN];
if (strcmp(ttname, "co") == 0) flag = 0;
if (strcmp(ttname, "?") == 0)
flag = KERN_PROC_TTY_NODEV;
else if (strcmp(ttname, "-") == 0)
flag = KERN_PROC_TTY_REVOKE;
else if (strcmp(ttname, "co") == 0)
ttypath = _PATH_CONSOLE; ttypath = _PATH_CONSOLE;
else if (*ttname != '/') else if (*ttname != '/')
(void)snprintf(ttypath = pathbuf, (void)snprintf(ttypath = pathbuf,
sizeof(pathbuf), "%s%s", _PATH_TTY, ttname); sizeof(pathbuf), "%s%s", _PATH_TTY, ttname);
else else
ttypath = ttname; ttypath = ttname;
if (stat(ttypath, &sb) == -1)
err(1, "%s", ttypath);
if (!S_ISCHR(sb.st_mode))
errx(1, "%s: not a terminal", ttypath);
what = KERN_PROC_TTY; what = KERN_PROC_TTY;
flag = sb.st_rdev; 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;
}
break; break;
} }
case 'U': case 'U':