Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/ps Use tty "?" to select processes with no controlling t...
details: https://anonhg.NetBSD.org/src/rev/1a9203cbaf62
branches: trunk
changeset: 484933:1a9203cbaf62
user: simonb <simonb%NetBSD.org@localhost>
date: Sat Apr 15 04:40:46 2000 +0000
description:
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.
diffstat:
bin/ps/ps.1 | 6 ++++--
bin/ps/ps.c | 23 +++++++++++++++--------
2 files changed, 19 insertions(+), 10 deletions(-)
diffs (71 lines):
diff -r a45e5eefa03c -r 1a9203cbaf62 bin/ps/ps.1
--- a/bin/ps/ps.1 Sat Apr 15 04:38:47 2000 +0000
+++ b/bin/ps/ps.1 Sat Apr 15 04:40:46 2000 +0000
@@ -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
.\" The Regents of the University of California. All rights reserved.
@@ -165,7 +165,9 @@
with the standard input.
.It Fl t
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
Displays processes belonging to the user whose username or uid has
been given to the
diff -r a45e5eefa03c -r 1a9203cbaf62 bin/ps/ps.c
--- a/bin/ps/ps.c Sat Apr 15 04:38:47 2000 +0000
+++ b/bin/ps/ps.c Sat Apr 15 04:40:46 2000 +0000
@@ -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
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94";
#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 /* not lint */
@@ -218,19 +218,26 @@
struct stat sb;
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;
else if (*ttname != '/')
(void)snprintf(ttypath = pathbuf,
sizeof(pathbuf), "%s%s", _PATH_TTY, ttname);
else
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;
- 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;
}
case 'U':
Home |
Main Index |
Thread Index |
Old Index