summaryrefslogtreecommitdiffstats
path: root/bin/ps/ps.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/ps/ps.c')
-rw-r--r--bin/ps/ps.c17
1 files changed, 14 insertions, 3 deletions
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