diff options
author | Karel Zak | 2011-07-21 16:44:55 +0200 |
---|---|---|
committer | Karel Zak | 2011-07-21 17:02:52 +0200 |
commit | 7ab08ba3e5e6f161b93ff2b3b7d5b18dc7b44510 (patch) | |
tree | b9c787bd479cb1cf1bd0efcf8cb542794eadc0bc /schedutils/ionice.c | |
parent | ionice: IOPRIO_PRIO_* macros (diff) | |
download | kernel-qcow2-util-linux-7ab08ba3e5e6f161b93ff2b3b7d5b18dc7b44510.tar.gz kernel-qcow2-util-linux-7ab08ba3e5e6f161b93ff2b3b7d5b18dc7b44510.tar.xz kernel-qcow2-util-linux-7ab08ba3e5e6f161b93ff2b3b7d5b18dc7b44510.zip |
ionice: fix -p
$ ionice 123
none: prio 4
none: prio 4
It calls ioprio_get(0x1, 0) and ioprio_get(0x1, 123), because the
code does not check it the "-p" options was specified.
The proper command line syntax is:
$ ionice -p 123
and the ioprio_get() should be called only once.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'schedutils/ionice.c')
-rw-r--r-- | schedutils/ionice.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/schedutils/ionice.c b/schedutils/ionice.c index f5f53a33a..a1bf31fd2 100644 --- a/schedutils/ionice.c +++ b/schedutils/ionice.c @@ -152,6 +152,11 @@ int main(int argc, char *argv[]) } } + if (!set && !pid && optind == argc) + errx(EXIT_FAILURE, _("PID or COMMAND not specified")); + if (!set && !pid) + errx(EXIT_FAILURE, _("scheduling for the COMMAND not specified")); + switch (ioclass) { case IOPRIO_CLASS_NONE: if (set & 1) @@ -185,8 +190,7 @@ int main(int argc, char *argv[]) pid = strtol_or_err(argv[optind], _("failed to parse pid")); ioprio_setpid(pid, ioclass, data); } - } - else if (argv[optind]) { + } else if (argv[optind]) { ioprio_setpid(0, ioclass, data); execvp(argv[optind], &argv[optind]); /* execvp should never return */ |