aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-06-30 22:20:43 +0000
committerRob Landley <rob@landley.net>2006-06-30 22:20:43 +0000
commit12d9419273c04dcdf2557f0263d69633c60b6a60 (patch)
treebf31bbda19a078002c20fc70776ebe749f54683e /miscutils
parent5df6d9f7777c0272365845e97ed836f61965a375 (diff)
downloadbusybox-w32-12d9419273c04dcdf2557f0263d69633c60b6a60.tar.gz
busybox-w32-12d9419273c04dcdf2557f0263d69633c60b6a60.tar.bz2
busybox-w32-12d9419273c04dcdf2557f0263d69633c60b6a60.zip
Revert taskset for 1.2.0. It emits a warning, breaks building under RH9,
and nobody seemed interested in fixing it despite repeated complaints. I'll worry about it in the 1.3 timeframe...
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/Config.in6
-rw-r--r--miscutils/Makefile.in1
-rw-r--r--miscutils/taskset.c67
3 files changed, 6 insertions, 68 deletions
diff --git a/miscutils/Config.in b/miscutils/Config.in
index 75a48c879..2d60fb65e 100644
--- a/miscutils/Config.in
+++ b/miscutils/Config.in
@@ -311,6 +311,12 @@ config CONFIG_TASKSET
311 help 311 help
312 Retrieve or set a processes's CPU affinity 312 Retrieve or set a processes's CPU affinity
313 313
314config CONFIG_TASKSET
315 bool "taskset"
316 default n
317 help
318 Retrieve or set a processes's CPU affinity (on linux)
319
314config CONFIG_TIME 320config CONFIG_TIME
315 bool "time" 321 bool "time"
316 default n 322 default n
diff --git a/miscutils/Makefile.in b/miscutils/Makefile.in
index d60d687b0..a0b6b7233 100644
--- a/miscutils/Makefile.in
+++ b/miscutils/Makefile.in
@@ -28,7 +28,6 @@ MISCUTILS-$(CONFIG_RUNLEVEL) += runlevel.o
28MISCUTILS-$(CONFIG_RX) += rx.o 28MISCUTILS-$(CONFIG_RX) += rx.o
29MISCUTILS-$(CONFIG_SETSID) += setsid.o 29MISCUTILS-$(CONFIG_SETSID) += setsid.o
30MISCUTILS-$(CONFIG_STRINGS) += strings.o 30MISCUTILS-$(CONFIG_STRINGS) += strings.o
31MISCUTILS-$(CONFIG_TASKSET) += taskset.o
32MISCUTILS-$(CONFIG_TIME) += time.o 31MISCUTILS-$(CONFIG_TIME) += time.o
33MISCUTILS-$(CONFIG_WATCHDOG) += watchdog.o 32MISCUTILS-$(CONFIG_WATCHDOG) += watchdog.o
34 33
diff --git a/miscutils/taskset.c b/miscutils/taskset.c
deleted file mode 100644
index a72f3ff53..000000000
--- a/miscutils/taskset.c
+++ /dev/null
@@ -1,67 +0,0 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * taskset - retrieve or set a processes's CPU affinity
4 * Copyright (c) 2006 Bernhard Fischer
5 *
6 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
7 */
8
9#include "busybox.h"
10#include <sched.h>
11#include <unistd.h>
12#include <getopt.h> /* optind */
13
14int taskset_main(int argc, char** argv)
15{
16 cpu_set_t mask, new_mask;
17 pid_t pid = 0;
18 unsigned long ul;
19 const char *state = "current\0new";
20 char *p_opt = NULL, *aff = NULL;
21
22 ul = bb_getopt_ulflags(argc, argv, "+p:", &p_opt);
23#define TASKSET_OPT_p (1)
24
25 if (ul & TASKSET_OPT_p) {
26 if (argc == optind+1) { /* -p <aff> <pid> */
27 aff = p_opt;
28 p_opt = argv[optind];
29 }
30 argv += optind; /* me -p <arg> */
31 pid = bb_xgetularg10_bnd(p_opt, 1, ULONG_MAX); /* -p <pid> */
32 } else
33 aff = *++argv; /* <aff> <cmd...> */
34 if (aff) {
35/* to_cpuset(bb_xgetularg_bnd(aff, 16, 1, ULONG_MAX), &new_mask); */
36 unsigned i = 0;
37 unsigned long l = bb_xgetularg_bnd(aff, 16, 1, ULONG_MAX);
38
39 CPU_ZERO(&new_mask);
40 while (i < CPU_SETSIZE && l >= (1<<i)) {
41 if ((1<<i) & l)
42 CPU_SET(i, &new_mask);
43 ++i;
44 }
45 }
46
47 if (ul & TASKSET_OPT_p) {
48print_aff:
49 if (sched_getaffinity(pid, sizeof (mask), &mask) < 0)
50 bb_perror_msg_and_die("Failed to %cet pid %d's affinity", 'g', pid);
51 bb_printf("pid %d's %s affinity mask: %x\n", /* %x .. perhaps _FANCY */
52 pid, state, mask);
53 if (!*argv) /* no new affinity given or we did print already, done. */
54 return EXIT_SUCCESS;
55 }
56
57 if (sched_setaffinity(pid, sizeof (new_mask), &new_mask))
58 bb_perror_msg_and_die("Failed to %cet pid %d's affinity", 's', pid);
59 if (ul & TASKSET_OPT_p) {
60 state += 8;
61 ++argv;
62 goto print_aff;
63 }
64 ++argv;
65 execvp(*argv, argv);
66 bb_perror_msg_and_die("%s", *argv);
67}