# HG changeset patch # User Rob Landley # Date 1375306617 18000 # Node ID 53a9bcb938f0ea2e8eeac08c4f9a366ab1dcd3e7 # Parent 6d3c39cb8a9d61f8a9a9065bbf1d06dd83494f50 Move renice from pending to posix, default y, fix link to standard. diff -r 6d3c39cb8a9d -r 53a9bcb938f0 toys/pending/renice.c --- a/toys/pending/renice.c Wed Jul 31 03:24:58 2013 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -/* renice.c - renice process - * - * Copyright 2013 CE Strake - * - * See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ - * See http://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/cmdbehav.html - -USE_RENICE(NEWTOY(renice, "<1gpun#|", TOYFLAG_BIN)) - -config RENICE - bool "renice" - default n - help - usage: renice [-gpu] -n increment ID ... -*/ - -#define FOR_renice -#include "toys.h" - -GLOBALS( - long nArgu; -) - -void renice_main(void) { - int which = (toys.optflags & FLAG_g) ? PRIO_PGRP : - ((toys.optflags & FLAG_u) ? PRIO_USER : PRIO_PROCESS); - char **arg; - - for (arg = toys.optargs; *arg; arg++) { - char *s = *arg; - int id = -1; - - if (toys.optflags & FLAG_u) { - struct passwd *p = getpwnam(s); - if (p) id = p->pw_uid; - } else { - id = strtol(s, &s, 10); - if (*s) id = -1; - } - - if (id < 0) { - error_msg("bad '%s'", *arg); - continue; - } - - if (setpriority(which, id, getpriority(which, id)+TT.nArgu) < 0) - perror_msg("setpriority %d", id); - } -} diff -r 6d3c39cb8a9d -r 53a9bcb938f0 toys/posix/renice.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/toys/posix/renice.c Wed Jul 31 16:36:57 2013 -0500 @@ -0,0 +1,48 @@ +/* renice.c - renice process + * + * Copyright 2013 CE Strake + * + * See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/renice.html + +USE_RENICE(NEWTOY(renice, "<1gpun#|", TOYFLAG_BIN)) + +config RENICE + bool "renice" + default y + help + usage: renice [-gpu] -n increment ID ... +*/ + +#define FOR_renice +#include "toys.h" + +GLOBALS( + long nArgu; +) + +void renice_main(void) { + int which = (toys.optflags & FLAG_g) ? PRIO_PGRP : + ((toys.optflags & FLAG_u) ? PRIO_USER : PRIO_PROCESS); + char **arg; + + for (arg = toys.optargs; *arg; arg++) { + char *s = *arg; + int id = -1; + + if (toys.optflags & FLAG_u) { + struct passwd *p = getpwnam(s); + if (p) id = p->pw_uid; + } else { + id = strtol(s, &s, 10); + if (*s) id = -1; + } + + if (id < 0) { + error_msg("bad '%s'", *arg); + continue; + } + + if (setpriority(which, id, getpriority(which, id)+TT.nArgu) < 0) + perror_msg("setpriority %d", id); + } +}