renice(1) rework
This commit is contained in:
parent
4dc2b783b8
commit
ee1e90ebdc
20
renice.c
20
renice.c
|
@ -1,4 +1,5 @@
|
||||||
/* See LICENSE file for copyright and license details. */
|
/* See LICENSE file for copyright and license details. */
|
||||||
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -23,6 +24,8 @@ main(int argc, char *argv[])
|
||||||
const char *adj = NULL;
|
const char *adj = NULL;
|
||||||
long val;
|
long val;
|
||||||
int i, which = PRIO_PROCESS, status = 0;
|
int i, which = PRIO_PROCESS, status = 0;
|
||||||
|
struct passwd *pw;
|
||||||
|
int who;
|
||||||
|
|
||||||
ARGBEGIN {
|
ARGBEGIN {
|
||||||
case 'n':
|
case 'n':
|
||||||
|
@ -47,20 +50,19 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
val = estrtol(adj, 10);
|
val = estrtol(adj, 10);
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
int who = -1;
|
who = -1;
|
||||||
|
|
||||||
if (which == PRIO_USER) {
|
if (which == PRIO_USER) {
|
||||||
const struct passwd *pwd;
|
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
do pwd = getpwnam(argv[i]); while (errno == EINTR);
|
pw = getpwnam(argv[i]);
|
||||||
if (pwd)
|
if (!pw) {
|
||||||
who = pwd->pw_uid;
|
if (errno != 0)
|
||||||
else if (errno != 0) {
|
weprintf("getpwnam %s:", argv[i]);
|
||||||
perror("can't read passwd");
|
else
|
||||||
|
weprintf("getpwnam %s: no user found\n", argv[i]);
|
||||||
status = 1;
|
status = 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
who = pw->pw_uid;
|
||||||
}
|
}
|
||||||
if (who < 0)
|
if (who < 0)
|
||||||
who = strtop(argv[i]);
|
who = strtop(argv[i]);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user