1 /* nice.c - Run a program at a different niceness level. 2 * 3 * Copyright 2010 Rob Landley <[email protected]> 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 -n Add given adjustment to priority (default 10) 23 */ 24 25 #define FOR_nice 26 #include "toys.h" 27 GLOBALS(long n;)28GLOBALS( 29 long n; 30 ) 31 32 void nice_main(void) 33 { 34 if (!toys.optflags) TT.n = 10; 35 36 errno = 0; 37 if (nice(TT.n)==-1 && errno) { 38 toys.exitval = 125; 39 perror_exit("Can't set priority"); 40 } 41 xexec(toys.optargs); 42 } 43