From 7ab08ba3e5e6f161b93ff2b3b7d5b18dc7b44510 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 21 Jul 2011 16:44:55 +0200 Subject: 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 --- schedutils/ionice.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'schedutils/ionice.c') 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 */ -- cgit v1.2.3-55-g7522