summaryrefslogtreecommitdiffstats
path: root/usr.bin/renice
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-08-05 06:42:48 +0000
committercharnier <charnier@FreeBSD.org>1997-08-05 06:42:48 +0000
commit86e0f07eddb1b5ae7960f483c58c2dad48bc1e83 (patch)
tree63cfbdaf826d2a08cdf1dbcb6281ea2e2bd838dd /usr.bin/renice
parentcb98d74e8de842c5d2026f29d67c598135e0e267 (diff)
downloadFreeBSD-src-86e0f07eddb1b5ae7960f483c58c2dad48bc1e83.zip
FreeBSD-src-86e0f07eddb1b5ae7960f483c58c2dad48bc1e83.tar.gz
Use err(3). Add usage() and prototypes.
Diffstat (limited to 'usr.bin/renice')
-rw-r--r--usr.bin/renice/renice.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/usr.bin/renice/renice.c b/usr.bin/renice/renice.c
index 37dd913..5962ed1 100644
--- a/usr.bin/renice/renice.c
+++ b/usr.bin/renice/renice.c
@@ -32,27 +32,37 @@
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1983, 1989, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
+#if 0
static char sccsid[] = "@(#)renice.c 8.1 (Berkeley) 6/9/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
+#include <err.h>
#include <stdio.h>
+#include <stdlib.h>
#include <pwd.h>
+int donice __P((int, int, int));
+static void usage __P((void));
+
/*
* Change the priority (nice) of processes
* or groups of processes which are already
* running.
*/
+int
main(argc, argv)
char **argv;
{
@@ -60,11 +70,8 @@ main(argc, argv)
int who = 0, prio, errs = 0;
argc--, argv++;
- if (argc < 2) {
- fprintf(stderr, "usage: renice priority [ [ -p ] pids ] ");
- fprintf(stderr, "[ [ -g ] pgrps ] [ [ -u ] users ]\n");
- exit(1);
- }
+ if (argc < 2)
+ usage();
prio = atoi(*argv);
argc--, argv++;
if (prio > PRIO_MAX)
@@ -88,16 +95,14 @@ main(argc, argv)
register struct passwd *pwd = getpwnam(*argv);
if (pwd == NULL) {
- fprintf(stderr, "renice: %s: unknown user\n",
- *argv);
+ warnx("%s: unknown user", *argv);
continue;
}
who = pwd->pw_uid;
} else {
who = atoi(*argv);
if (who < 0) {
- fprintf(stderr, "renice: %s: bad value\n",
- *argv);
+ warnx("%s: bad value", *argv);
continue;
}
}
@@ -106,6 +111,15 @@ main(argc, argv)
exit(errs != 0);
}
+static void
+usage()
+{
+ fprintf(stderr,
+"usage: renice priority [ [ -p ] pids ] [ [ -g ] pgrps ] [ [ -u ] users ]\n");
+ exit(1);
+}
+
+int
donice(which, who, prio)
int which, who, prio;
{
@@ -114,13 +128,11 @@ donice(which, who, prio)
errno = 0, oldprio = getpriority(which, who);
if (oldprio == -1 && errno) {
- fprintf(stderr, "renice: %d: ", who);
- perror("getpriority");
+ warn("%d: getpriority", who);
return (1);
}
if (setpriority(which, who, prio) < 0) {
- fprintf(stderr, "renice: %d: ", who);
- perror("setpriority");
+ warn("%d: setpriority", who);
return (1);
}
printf("%d: old priority %d, new priority %d\n", who, oldprio, prio);
OpenPOWER on IntegriCloud