Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4973 | right-hear | 1 | /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */ |
2 | #include |
||
3 | #include |
||
4 | |||
5 | /* The references disagree on the values of these. Higher value |
||
6 | means less important process. */ |
||
7 | #define NICE_MIN -20 |
||
8 | #define NICE_MAX +20 |
||
9 | #define NICE_USER 0 |
||
10 | |||
11 | static int nice_val = NICE_USER; |
||
12 | |||
13 | int nice (int incr) |
||
14 | { |
||
15 | if (incr < 0 && getuid () != 0) { |
||
16 | errno = EPERM; |
||
17 | return -1; |
||
18 | } |
||
19 | |||
20 | nice_val += incr; |
||
21 | if (nice_val < NICE_MIN) nice_val = NICE_MIN; |
||
22 | if (nice_val > NICE_MAX) nice_val = NICE_MAX; |
||
23 | |||
24 | /* This is braindead by design! If -1 returned you don't know |
||
25 | if you had an error! Luckily you can ignore errors for a |
||
26 | function like this. */ |
||
27 | errno = 0; |
||
28 | return (nice_val - NICE_USER); |
||
29 | }>> |