[hackers] [sbase] renice(1) rework || sin

From: <git_AT_suckless.org>
Date: Mon, 17 Nov 2014 17:33:42 +0100

commit ee1e90ebdcc2cbe29d91c5317d19b89b6b56e5e2
Author: sin <sin_AT_2f30.org>
Date: Mon Nov 17 16:32:30 2014 +0000

    renice(1) rework

diff --git a/renice.c b/renice.c
index 06cbc46..5d7e10e 100644
--- a/renice.c
+++ b/renice.c
_AT_@ -1,4 +1,5 @@
 /* See LICENSE file for copyright and license details. */
+#include <errno.h>
 #include <limits.h>
 #include <pwd.h>
 #include <stdio.h>
_AT_@ -23,6 +24,8 @@ main(int argc, char *argv[])
         const char *adj = NULL;
         long val;
         int i, which = PRIO_PROCESS, status = 0;
+ struct passwd *pw;
+ int who;
 
         ARGBEGIN {
         case 'n':
_AT_@ -47,20 +50,19 @@ main(int argc, char *argv[])
 
         val = estrtol(adj, 10);
         for (i = 0; i < argc; i++) {
- int who = -1;
-
+ who = -1;
                 if (which == PRIO_USER) {
- const struct passwd *pwd;
-
                         errno = 0;
- do pwd = getpwnam(argv[i]); while (errno == EINTR);
- if (pwd)
- who = pwd->pw_uid;
- else if (errno != 0) {
- perror("can't read passwd");
+ pw = getpwnam(argv[i]);
+ if (!pw) {
+ if (errno != 0)
+ weprintf("getpwnam %s:", argv[i]);
+ else
+ weprintf("getpwnam %s: no user found\n", argv[i]);
                                 status = 1;
                                 continue;
                         }
+ who = pw->pw_uid;
                 }
                 if (who < 0)
                         who = strtop(argv[i]);
Received on Mon Nov 17 2014 - 17:33:42 CET

This archive was generated by hypermail 2.3.0 : Mon Nov 17 2014 - 17:36:17 CET