X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=miscutils%2Fionice.c;h=5fcb653a839485c044e17cb4f71f0882c1e48492;hb=237bedd499c58034a1355484d6d4d906f0180308;hp=361c141b82d4859542af304918f77ef4ccdd9244;hpb=3266aa9ec285dbcf254daa17c103bf69dc755967;p=oweals%2Fbusybox.git diff --git a/miscutils/ionice.c b/miscutils/ionice.c index 361c141b8..5fcb653a8 100644 --- a/miscutils/ionice.c +++ b/miscutils/ionice.c @@ -4,9 +4,16 @@ * * Copyright (C) 2008 by * - * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. + * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ +//usage:#define ionice_trivial_usage +//usage: "[-c 1-3] [-n 0-7] [-p PID] [PROG]" +//usage:#define ionice_full_usage "\n\n" +//usage: "Change I/O priority and class\n" +//usage: "\n -c Class. 1:realtime 2:best-effort 3:idle" +//usage: "\n -n Priority" + #include #include #include "libbb.h" @@ -34,7 +41,7 @@ enum { IOPRIO_CLASS_IDLE }; -static const char to_prio[] = "none\0realtime\0best-effort\0idle"; +static const char to_prio[] ALIGN1 = "none\0realtime\0best-effort\0idle"; #define IOPRIO_CLASS_SHIFT 13 @@ -53,9 +60,8 @@ int ionice_main(int argc UNUSED_PARAM, char **argv) }; /* Numeric params */ - opt_complementary = "n+:c+:p+"; /* '+': stop at first non-option */ - opt = getopt32(argv, "+n:c:p:", &pri, &ioclass, &pid); + opt = getopt32(argv, "+n:+c:+p:+", &pri, &ioclass, &pid); argv += optind; if (opt & OPT_c) { @@ -73,7 +79,7 @@ int ionice_main(int argc UNUSED_PARAM, char **argv) if (!(opt & (OPT_n|OPT_c))) { if (!(opt & OPT_p) && *argv) - pid = xatoi_u(*argv); + pid = xatoi_positive(*argv); pri = ioprio_get(IOPRIO_WHO_PROCESS, pid); if (pri == -1) @@ -89,9 +95,8 @@ int ionice_main(int argc UNUSED_PARAM, char **argv) pri |= (ioclass << IOPRIO_CLASS_SHIFT); if (ioprio_set(IOPRIO_WHO_PROCESS, pid, pri) == -1) bb_perror_msg_and_die("ioprio_%cet", 's'); - if (*argv) { - BB_EXECVP(*argv, argv); - bb_simple_perror_msg_and_die(*argv); + if (argv[0]) { + BB_EXECVP_or_die(argv); } }