summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bin/ps/ps.16
-rw-r--r--bin/ps/ps.c17
2 files changed, 19 insertions, 4 deletions
diff --git a/bin/ps/ps.1 b/bin/ps/ps.1
index 0c73e17..7dd9475 100644
--- a/bin/ps/ps.1
+++ b/bin/ps/ps.1
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)ps.1 8.3 (Berkeley) 4/18/94
-.\" $Id$
+.\" $Id: ps.1,v 1.4 1994/09/24 02:56:46 davidg Exp $
.\"
.Dd April 18, 1994
.Dt PS 1
@@ -47,6 +47,7 @@
.Op Fl o Ar fmt
.Op Fl p Ar pid
.Op Fl t Ar tty
+.Op Fl U Ar username
.Op Fl W Ar swap
.Nm ps
.Op Fl L
@@ -130,6 +131,9 @@ with the standard input.
.It Fl t
Display information about processes attached to the specified terminal
device.
+.It Fl U
+Display the processes belonging to the specified
+.Tn username .
.It Fl u
Display information associated with the following keywords:
user, pid, %cpu, %mem, vsz, rss, tt, state, start, time and command.
diff --git a/bin/ps/ps.c b/bin/ps/ps.c
index fae17b2..0899212 100644
--- a/bin/ps/ps.c
+++ b/bin/ps/ps.c
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: ps.c,v 1.8 1995/10/23 21:06:31 ache Exp $
+ * $Id: ps.c,v 1.9 1995/10/26 10:57:52 ache Exp $
*/
#ifndef lint
@@ -64,6 +64,7 @@ static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94";
#include <string.h>
#include <unistd.h>
#include <locale.h>
+#include <pwd.h>
#include "ps.h"
@@ -110,6 +111,7 @@ main(argc, argv)
struct kinfo_proc *kp;
struct varent *vent;
struct winsize ws;
+ struct passwd *pwd;
dev_t ttydev;
pid_t pid;
uid_t uid;
@@ -136,7 +138,7 @@ main(argc, argv)
ttydev = NODEV;
memf = nlistf = swapf = NULL;
while ((ch = getopt(argc, argv,
- "aCeghjLlM:mN:O:o:p:rSTt:uvW:wx")) != EOF)
+ "aCeghjLlM:mN:O:o:p:rSTt:U:uvW:wx")) != EOF)
switch((char)ch) {
case 'a':
all = 1;
@@ -217,6 +219,14 @@ main(argc, argv)
ttydev = sb.st_rdev;
break;
}
+ case 'U':
+ pwd = getpwnam(optarg);
+ if (pwd == NULL)
+ errx(1, "%s: no such user", optarg);
+ uid = pwd->pw_uid;
+ endpwent();
+ xflg++; /* XXX: intuitive? */
+ break;
case 'u':
parsefmt(ufmt);
sortby = SORTCPU;
@@ -274,7 +284,8 @@ main(argc, argv)
if (!fmt)
parsefmt(dfmt);
- if (!all && ttydev == NODEV && pid == -1) /* XXX - should be cleaner */
+ /* XXX - should be cleaner */
+ if (!all && ttydev == NODEV && pid == -1 && uid == (uid_t)-1)
uid = getuid();
/*
OpenPOWER on IntegriCloud