diff options
Diffstat (limited to 'procps')
-rw-r--r-- | procps/Config.src | 7 | ||||
-rw-r--r-- | procps/kill.c | 1 | ||||
-rw-r--r-- | procps/pwdx.c | 60 |
3 files changed, 65 insertions, 3 deletions
diff --git a/procps/Config.src b/procps/Config.src index cf664eeb2..3e7df0b81 100644 --- a/procps/Config.src +++ b/procps/Config.src | |||
@@ -10,7 +10,7 @@ INSERT | |||
10 | config FREE | 10 | config FREE |
11 | bool "free" | 11 | bool "free" |
12 | default y | 12 | default y |
13 | depends on PLATFORM_LINUX #sysinfo() | 13 | select PLATFORM_LINUX #sysinfo() |
14 | help | 14 | help |
15 | free displays the total amount of free and used physical and swap | 15 | free displays the total amount of free and used physical and swap |
16 | memory in the system, as well as the buffers used by the kernel. | 16 | memory in the system, as well as the buffers used by the kernel. |
@@ -99,7 +99,8 @@ config FEATURE_PS_WIDE | |||
99 | config FEATURE_PS_TIME | 99 | config FEATURE_PS_TIME |
100 | bool "Enable time and elapsed time output" | 100 | bool "Enable time and elapsed time output" |
101 | default y | 101 | default y |
102 | depends on PS && DESKTOP && PLATFORM_LINUX #sysinfo() | 102 | depends on PS && DESKTOP |
103 | select PLATFORM_LINUX | ||
103 | help | 104 | help |
104 | Support -o time and -o etime output specifiers. | 105 | Support -o time and -o etime output specifiers. |
105 | 106 | ||
@@ -196,7 +197,7 @@ config FEATURE_SHOW_THREADS | |||
196 | config UPTIME | 197 | config UPTIME |
197 | bool "uptime" | 198 | bool "uptime" |
198 | default y | 199 | default y |
199 | depends on PLATFORM_LINUX #sysinfo() | 200 | select PLATFORM_LINUX #sysinfo() |
200 | help | 201 | help |
201 | uptime gives a one line display of the current time, how long | 202 | uptime gives a one line display of the current time, how long |
202 | the system has been running, how many users are currently logged | 203 | the system has been running, how many users are currently logged |
diff --git a/procps/kill.c b/procps/kill.c index e6f27af50..599152250 100644 --- a/procps/kill.c +++ b/procps/kill.c | |||
@@ -221,6 +221,7 @@ int kill_main(int argc, char **argv) | |||
221 | pid = bb_strtoi(arg, &end, 10); | 221 | pid = bb_strtoi(arg, &end, 10); |
222 | if (errno && (errno != EINVAL || *end != ' ')) { | 222 | if (errno && (errno != EINVAL || *end != ' ')) { |
223 | bb_error_msg("invalid number '%s'", arg); | 223 | bb_error_msg("invalid number '%s'", arg); |
224 | *end = '\0'; | ||
224 | errors++; | 225 | errors++; |
225 | } else if (kill(pid, signo) != 0) { | 226 | } else if (kill(pid, signo) != 0) { |
226 | bb_perror_msg("can't kill pid %d", (int)pid); | 227 | bb_perror_msg("can't kill pid %d", (int)pid); |
diff --git a/procps/pwdx.c b/procps/pwdx.c new file mode 100644 index 000000000..781810488 --- /dev/null +++ b/procps/pwdx.c | |||
@@ -0,0 +1,60 @@ | |||
1 | /* vi: set sw=4 ts=4: */ | ||
2 | /* | ||
3 | * pwdx implementation for busybox | ||
4 | * | ||
5 | * Copyright (c) 2004 Nicholas Miell | ||
6 | * ported from procps by Pere Orga <gotrunks@gmail.com> 2011 | ||
7 | * | ||
8 | * Licensed under GPLv2, see file LICENSE in this source tree. | ||
9 | */ | ||
10 | |||
11 | //config:config PWDX | ||
12 | //config: bool "pwdx" | ||
13 | //config: default y | ||
14 | //config: help | ||
15 | //config: Report current working directory of a process | ||
16 | |||
17 | //applet:IF_PWDX(APPLET(pwdx, BB_DIR_USR_BIN, BB_SUID_DROP)) | ||
18 | |||
19 | //kbuild:lib-$(CONFIG_PWDX) += pwdx.o | ||
20 | |||
21 | //usage:#define pwdx_trivial_usage | ||
22 | //usage: "PID..." | ||
23 | //usage:#define pwdx_full_usage "\n\n" | ||
24 | //usage: "Show current directory for PIDs\n" | ||
25 | |||
26 | #include "libbb.h" | ||
27 | |||
28 | int pwdx_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | ||
29 | int pwdx_main(int argc UNUSED_PARAM, char **argv) | ||
30 | { | ||
31 | opt_complementary = "-1"; | ||
32 | getopt32(argv, ""); | ||
33 | argv += optind; | ||
34 | |||
35 | do { | ||
36 | char buf[sizeof("/proc/%u/cwd") + sizeof(int)*3]; | ||
37 | unsigned pid; | ||
38 | char *s; | ||
39 | char *arg = *argv; | ||
40 | |||
41 | // Allowed on the command line: | ||
42 | // /proc/NUM | ||
43 | // NUM | ||
44 | if (strncmp(arg, "/proc/", 6) == 0) | ||
45 | arg += 6; | ||
46 | |||
47 | pid = bb_strtou(arg, NULL, 10); | ||
48 | if (errno) | ||
49 | bb_error_msg_and_die("invalid process id: '%s'", arg); | ||
50 | |||
51 | sprintf(buf, "/proc/%u/cwd", pid); | ||
52 | |||
53 | s = xmalloc_readlink(buf); | ||
54 | // "pwdx /proc/1" says "/proc/1: DIR", not "1: DIR" | ||
55 | printf("%s: %s\n", *argv, s ? s : strerror(errno == ENOENT ? ESRCH : errno)); | ||
56 | free(s); | ||
57 | } while (*++argv); | ||
58 | |||
59 | return EXIT_SUCCESS; | ||
60 | } | ||