1 /* nice.c - Run a program at a different niceness level. 2 * 3 * Copyright 2010 Rob Landley <rob@landley.net> 4 * 5 * See http://opengroup.org/onlinepubs/9699919799/utilities/nice.html 6 7 USE_NICE(NEWTOY(nice, "^<1n#", TOYFLAG_BIN)) 8 9 config NICE 10 bool "nice" 11 default y 12 help 13 usage: nice [-n PRIORITY] COMMAND... 14 15 Run a command line at an increased or decreased scheduling priority. 16 17 Higher numbers make a program yield more CPU time, from -20 (highest 18 priority) to 19 (lowest). By default processes inherit their parent's 19 niceness (usually 0). By default this command adds 10 to the parent's 20 priority. Only root can set a negative niceness level. 21 */ 22 23 #define FOR_nice 24 #include "toys.h" 25 GLOBALS(long n;)26GLOBALS( 27 long n; 28 ) 29 30 void nice_main(void) 31 { 32 if (!toys.optflags) TT.n = 10; 33 34 errno = 0; 35 if (nice(TT.n)==-1 && errno) { 36 toys.exitval = 125; 37 perror_exit("Can't set priority"); 38 } 39 xexec(toys.optargs); 40 } 41