summaryrefslogtreecommitdiffstats
path: root/schedutils
diff options
context:
space:
mode:
authorMatthias Koenig2007-07-16 13:10:59 +0200
committerKarel Zak2007-07-16 15:12:36 +0200
commit697d58e867d6c2a5746f495cb5cab24994ce808e (patch)
tree6f55d2f17f5e51d6cc57563dd96b3d0e3d5ea235 /schedutils
parentmount: add acl option documentation for ext3 and reiserfs (diff)
downloadkernel-qcow2-util-linux-697d58e867d6c2a5746f495cb5cab24994ce808e.tar.gz
kernel-qcow2-util-linux-697d58e867d6c2a5746f495cb5cab24994ce808e.tar.xz
kernel-qcow2-util-linux-697d58e867d6c2a5746f495cb5cab24994ce808e.zip
schedutils: fix chrt docs and pid=0 usage
Fix some documentation bugs for chrt. Make it work with PID 0, which means current process. Signed-off-by: Matthias Koenig <mkoenig@suse.de>
Diffstat (limited to 'schedutils')
-rw-r--r--schedutils/chrt.16
-rw-r--r--schedutils/chrt.c10
2 files changed, 9 insertions, 7 deletions
diff --git a/schedutils/chrt.1 b/schedutils/chrt.1
index effa19033..01f7650cf 100644
--- a/schedutils/chrt.1
+++ b/schedutils/chrt.1
@@ -79,13 +79,13 @@ output version information and exit
.SH USAGE
.TP
The default behavior is to run a new command::
-chrt [prio] [command] [arguments]
+chrt prio command [arguments]
.TP
You can also retrieve the real-time attributes of an existing task:
-chrt -p [pid]
+chrt -p pid
.TP
Or set them:
-chrt -p [prio] [pid]
+chrt -p prio pid
.SH PERMISSIONS
A user must possess
.BR CAP_SYS_NICE
diff --git a/schedutils/chrt.c b/schedutils/chrt.c
index 02ff3809c..30892d8bc 100644
--- a/schedutils/chrt.c
+++ b/schedutils/chrt.c
@@ -46,7 +46,7 @@ static void show_usage(const char *cmd)
fprintf(stderr, " -b, --batch "
"set policy to SCHED_BATCH\n");
fprintf(stderr, " -f, --fifo "
- "set policy to SCHED_FF\n");
+ "set policy to SCHED_FIFO\n");
fprintf(stderr, " -p, --pid "
"operate on existing given pid\n");
fprintf(stderr, " -m, --max "
@@ -146,7 +146,7 @@ int main(int argc, char *argv[])
{
int i, policy = SCHED_RR, priority = 0, verbose = 0;
struct sched_param sp;
- pid_t pid = 0;
+ pid_t pid = -1;
struct option longopts[] = {
{ "batch", 0, NULL, 'b' },
@@ -205,12 +205,12 @@ int main(int argc, char *argv[])
}
- if ((pid && argc - optind < 1) || (!pid && argc - optind < 2)) {
+ if (((pid > -1) && argc - optind < 1) || ((pid == -1) && argc - optind < 2)) {
show_usage(argv[0]);
return 1;
}
- if (pid && (verbose || argc - optind == 1)) {
+ if ((pid > -1) && (verbose || argc - optind == 1)) {
show_rt_info("current", pid);
if (argc - optind == 1)
return 0;
@@ -224,6 +224,8 @@ int main(int argc, char *argv[])
return 1;
}
+ if (pid == -1)
+ pid = 0;
sp.sched_priority = priority;
if (sched_setscheduler(pid, policy, &sp) == -1) {
perror("sched_setscheduler");