summaryrefslogtreecommitdiff
path: root/usr.bin/top/commands.c
diff options
context:
space:
mode:
authorJean-Francois Brousseau <jfb@cvs.openbsd.org>2003-06-17 00:51:30 +0000
committerJean-Francois Brousseau <jfb@cvs.openbsd.org>2003-06-17 00:51:30 +0000
commit8c081a572de37430e988e57db5063ee3dad23f7d (patch)
treed52061ab0765ca95e8fb5326efca15ef61de5d3e /usr.bin/top/commands.c
parentdc8d969d73aa0fba53f5753d69c3ecd9fd829d95 (diff)
properly typecast to uid_t the return value of proc_owner() and report
ESRCH instead of EACCES if it returns -1 ok millert@
Diffstat (limited to 'usr.bin/top/commands.c')
-rw-r--r--usr.bin/top/commands.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.bin/top/commands.c b/usr.bin/top/commands.c
index e88892c6359..77d51e8e04d 100644
--- a/usr.bin/top/commands.c
+++ b/usr.bin/top/commands.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: commands.c,v 1.10 2003/06/15 16:24:44 millert Exp $ */
+/* $OpenBSD: commands.c,v 1.11 2003/06/17 00:51:29 jfb Exp $ */
/*
* Top users/processes display for Unix
@@ -319,7 +319,7 @@ kill_procs(char *str)
{
int signum = SIGTERM, procnum;
struct sigdesc *sigp;
- uid_t uid;
+ uid_t uid, puid;
char *nptr;
/* reset error array */
@@ -363,7 +363,10 @@ kill_procs(char *str)
ERROR(str, 0);
} else {
/* check process owner if we're not root */
- if (uid && (uid != proc_owner(procnum))) {
+ puid = proc_owner(procnum);
+ if (puid == (uid_t)(-1)) {
+ ERROR(str, ESRCH);
+ } else if (uid && (uid != puid)) {
ERROR(str, EACCES);
} else if (kill(procnum, signum) == -1) {
ERROR(str, errno);