comparison toys/posix/nice.c @ 653:2986aa63a021

Move commands into "posix", "lsb", and "other" menus/directories.
author Rob Landley <rob@landley.net>
date Sat, 25 Aug 2012 14:25:22 -0500
parents toys/nice.c@2364ace48ab1
children 6df4ccc0acbe
comparison
equal deleted inserted replaced
652:2d7c56913fda 653:2986aa63a021
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
19 Higher numbers make a program yield more CPU time, from -20 (highest
20 priority) to 19 (lowest). By default processes inherit their parent's
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 errno = 0;
38 if (nice(TT.priority)==-1 && errno) perror_exit("Can't set priority");
39
40 xexec(toys.optargs);
41 }