1 /* renice.c - renice process
3 * Copyright 2013 CE Strake <strake888 at gmail.com>
5 * See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/renice.html
7 USE_RENICE(NEWTOY(renice, "<1gpun#|", TOYFLAG_USR|TOYFLAG_BIN))
13 usage: renice [-gpu] -n increment ID ...
23 void renice_main(void) {
24 int which = (toys.optflags & FLAG_g) ? PRIO_PGRP :
25 ((toys.optflags & FLAG_u) ? PRIO_USER : PRIO_PROCESS);
28 for (arg = toys.optargs; *arg; arg++) {
32 if (toys.optflags & FLAG_u) {
33 struct passwd *p = getpwnam(s);
34 if (p) id = p->pw_uid;
36 id = strtol(s, &s, 10);
41 error_msg("bad '%s'", *arg);
45 if (setpriority(which, id, getpriority(which, id)+TT.nArgu) < 0)
46 perror_msg("setpriority %d", id);