basename,dirname,freeramdisk,rx,raidautorun,runsv,chvt: skip "--" argument
[oweals/busybox.git] / miscutils / taskset.c
index a0bbf0aa190e320942b42f4b6d5a0a3b4a8048e3..77fc8643d5eba73bca5a613de9bb09db1eae80ba 100644 (file)
@@ -3,9 +3,27 @@
  * taskset - retrieve or set a processes' CPU affinity
  * Copyright (c) 2006 Bernhard Reutner-Fischer
  *
- * 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 taskset_trivial_usage
+//usage:       "[-p] [MASK] [PID | PROG ARGS]"
+//usage:#define taskset_full_usage "\n\n"
+//usage:       "Set or get CPU affinity\n"
+//usage:     "\nOptions:"
+//usage:     "\n       -p      Operate on an existing PID"
+//usage:
+//usage:#define taskset_example_usage
+//usage:       "$ taskset 0x7 ./dgemm_test&\n"
+//usage:       "$ taskset -p 0x1 $!\n"
+//usage:       "pid 4790's current affinity mask: 7\n"
+//usage:       "pid 4790's new affinity mask: 1\n"
+//usage:       "$ taskset 0x7 /bin/sh -c './taskset -p 0x1 $$'\n"
+//usage:       "pid 6671's current affinity mask: 1\n"
+//usage:       "pid 6671's new affinity mask: 1\n"
+//usage:       "$ taskset -p 1\n"
+//usage:       "pid 1's current affinity mask: 3\n"
+
 #include <sched.h>
 #include "libbb.h"
 
@@ -129,9 +147,8 @@ int taskset_main(int argc UNUSED_PARAM, char **argv)
        if (sched_setaffinity(pid, sizeof(mask), &mask))
                bb_perror_msg_and_die("can't %cet pid %d's affinity", 's', pid);
 
-       if (!*argv) /* "-p <aff> <pid> [...ignored...]" */
+       if (!argv[0]) /* "-p <aff> <pid> [...ignored...]" */
                goto print_aff; /* print new affinity and exit */
 
-       BB_EXECVP(*argv, argv);
-       bb_simple_perror_msg_and_die(*argv);
+       BB_EXECVP_or_die(argv);
 }