Mercurial > hg > toybox
annotate toys/nice.c @ 446:b51faa4fe8e6
Correct description of nice levels in help of nice
author | Elie De Brauwer <eliedebrauwer@gmail.com> |
---|---|
date | Fri, 10 Feb 2012 13:36:48 +0100 |
parents | d3ca5e15e457 |
children | 2364ace48ab1 |
rev | line source |
---|---|
374 | 1 /* vi: set sw=4 ts=4: |
2 * | |
3 * nice.c - Run a program at a different niceness level. | |
4 * | |
5 * Copyright 2010 Rob Landley <rob@landley.net> | |
6 * | |
7 * See http://www.opengroup.org/onlinepubs/9699919799/utilities/nice.html | |
8 | |
9 USE_NICE(NEWTOY(nice, "^<1n#", TOYFLAG_USR|TOYFLAG_BIN)) | |
10 | |
11 config NICE | |
12 bool "nice" | |
13 default y | |
14 help | |
15 usage: nice [-n PRIORITY] command [args...] | |
16 | |
17 Run a command line at an increased or decreased scheduling priority. | |
18 | |
446
b51faa4fe8e6
Correct description of nice levels in help of nice
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
444
diff
changeset
|
19 Higher numbers make a program yield more CPU time, from -20 (highest |
b51faa4fe8e6
Correct description of nice levels in help of nice
Elie De Brauwer <eliedebrauwer@gmail.com>
parents:
444
diff
changeset
|
20 priority) to 19 (lowest). By default processes inherit their parent's |
374 | 21 niceness (usually 0). By default this command adds 10 to the parent's |
22 priority. Only root can set a negative niceness level. | |
23 */ | |
24 | |
25 #include "toys.h" | |
26 | |
27 DEFINE_GLOBALS( | |
28 long priority; | |
29 ) | |
30 | |
31 #define TT this.nice | |
32 | |
33 void nice_main(void) | |
34 { | |
35 if (!toys.optflags) TT.priority = 10; | |
36 | |
37 nice(TT.priority); | |
38 if (getpriority(PRIO_PROCESS, getpid()) != TT.priority) | |
39 perror_exit("Can't set priority"); | |
40 | |
41 xexec(toys.optargs); | |
42 } |