diff options
Diffstat (limited to 'miscutils')
-rw-r--r-- | miscutils/chrt.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/miscutils/chrt.c b/miscutils/chrt.c index e2b7f8ae0..3d0da58ca 100644 --- a/miscutils/chrt.c +++ b/miscutils/chrt.c | |||
@@ -5,33 +5,35 @@ | |||
5 | * | 5 | * |
6 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. | 6 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
7 | */ | 7 | */ |
8 | |||
9 | #include <sched.h> | 8 | #include <sched.h> |
10 | #include "libbb.h" | 9 | #include "libbb.h" |
11 | #ifndef _POSIX_PRIORITY_SCHEDULING | 10 | #ifndef _POSIX_PRIORITY_SCHEDULING |
12 | #warning your system may be foobared | 11 | #warning your system may be foobared |
13 | #endif | 12 | #endif |
13 | |||
14 | static const struct { | 14 | static const struct { |
15 | int policy; | 15 | int policy; |
16 | char name[12]; | 16 | char name[sizeof("SCHED_OTHER")]; |
17 | } policies[] = { | 17 | } policies[] = { |
18 | {SCHED_OTHER, "SCHED_OTHER"}, | 18 | {SCHED_OTHER, "SCHED_OTHER"}, |
19 | {SCHED_FIFO, "SCHED_FIFO"}, | 19 | {SCHED_FIFO, "SCHED_FIFO"}, |
20 | {SCHED_RR, "SCHED_RR"} | 20 | {SCHED_RR, "SCHED_RR"} |
21 | }; | 21 | }; |
22 | 22 | ||
23 | //TODO: add | ||
24 | // -b, SCHED_BATCH | ||
25 | // -i, SCHED_IDLE | ||
26 | |||
23 | static void show_min_max(int pol) | 27 | static void show_min_max(int pol) |
24 | { | 28 | { |
25 | const char *fmt = "%s min/max priority\t: %d/%d\n\0%s not supported?\n"; | 29 | const char *fmt = "%s min/max priority\t: %u/%u\n"; |
26 | int max, min; | 30 | int max, min; |
31 | |||
27 | max = sched_get_priority_max(pol); | 32 | max = sched_get_priority_max(pol); |
28 | min = sched_get_priority_min(pol); | 33 | min = sched_get_priority_min(pol); |
29 | if (max >= 0 && min >= 0) | 34 | if ((max|min) < 0) |
30 | printf(fmt, policies[pol].name, min, max); | 35 | fmt = "%s not supported\n"; |
31 | else { | 36 | printf(fmt, policies[pol].name, min, max); |
32 | fmt += 29; | ||
33 | printf(fmt, policies[pol].name); | ||
34 | } | ||
35 | } | 37 | } |
36 | 38 | ||
37 | #define OPT_m (1<<0) | 39 | #define OPT_m (1<<0) |