* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
static char sccsid
[] = "@(#)renice.c 5.1 (Berkeley) %G%";
#include <sys/resource.h>
* Change the priority (nice) of processes
* or groups of processes which are already
int which
= PRIO_PROCESS
;
int who
= 0, prio
, errs
= 0;
fprintf(stderr
, "usage: renice priority [ [ -p ] pids ] ");
fprintf(stderr
, "[ [ -g ] pgrps ] [ [ -u ] users ]\n");
for (; argc
> 0; argc
--, argv
++) {
if (strcmp(*argv
, "-g") == 0) {
if (strcmp(*argv
, "-u") == 0) {
if (strcmp(*argv
, "-p") == 0) {
if (which
== PRIO_USER
) {
register struct passwd
*pwd
= getpwnam(*argv
);
fprintf(stderr
, "renice: %s: unknown user\n",
fprintf(stderr
, "renice: %s: bad value\n",
errs
+= donice(which
, who
, prio
);
errno
= 0, oldprio
= getpriority(which
, who
);
if (oldprio
== -1 && errno
) {
fprintf(stderr
, "renice: %d: ", who
);
if (setpriority(which
, who
, prio
) < 0) {
fprintf(stderr
, "renice: %d: ", who
);
printf("%d: old priority %d, new priority %d\n", who
, oldprio
, prio
);