diff options
| author | Ron Yorston <rmy@pobox.com> | 2023-01-05 08:56:27 +0000 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2023-01-05 08:56:27 +0000 |
| commit | e5e4a2fec5435192d1672e6db2f335cb5e89f877 (patch) | |
| tree | 08cb827a40817ea4824bc9336d57eda669c4d4b2 /procps | |
| parent | 4343f3926355f55fc023203c992527fc34bf609e (diff) | |
| parent | b1884deb514c35289d37e7bfbf23f770b0bd09b3 (diff) | |
| download | busybox-w32-e5e4a2fec5435192d1672e6db2f335cb5e89f877.tar.gz busybox-w32-e5e4a2fec5435192d1672e6db2f335cb5e89f877.tar.bz2 busybox-w32-e5e4a2fec5435192d1672e6db2f335cb5e89f877.zip | |
Merge branch 'busybox' into merge
Diffstat (limited to 'procps')
| -rw-r--r-- | procps/pgrep.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/procps/pgrep.c b/procps/pgrep.c index 6d25c247e..82e00322f 100644 --- a/procps/pgrep.c +++ b/procps/pgrep.c | |||
| @@ -44,7 +44,7 @@ | |||
| 44 | //usage: "\n -P Match parent process ID" | 44 | //usage: "\n -P Match parent process ID" |
| 45 | //usage: | 45 | //usage: |
| 46 | //usage:#define pkill_trivial_usage | 46 | //usage:#define pkill_trivial_usage |
| 47 | //usage: "[-l|-SIGNAL] [-xfvno] [-s SID|-P PPID|PATTERN]" | 47 | //usage: "[-l|-SIGNAL] [-xfvnoe] [-s SID|-P PPID|PATTERN]" |
| 48 | //usage:#define pkill_full_usage "\n\n" | 48 | //usage:#define pkill_full_usage "\n\n" |
| 49 | //usage: "Send signal to processes selected by regex PATTERN\n" | 49 | //usage: "Send signal to processes selected by regex PATTERN\n" |
| 50 | //usage: "\n -l List all signals" | 50 | //usage: "\n -l List all signals" |
| @@ -55,6 +55,7 @@ | |||
| 55 | //usage: "\n -v Negate the match" | 55 | //usage: "\n -v Negate the match" |
| 56 | //usage: "\n -n Signal the newest process only" | 56 | //usage: "\n -n Signal the newest process only" |
| 57 | //usage: "\n -o Signal the oldest process only" | 57 | //usage: "\n -o Signal the oldest process only" |
| 58 | //usage: "\n -e Display name and PID of the process being killed" | ||
| 58 | 59 | ||
| 59 | #include "libbb.h" | 60 | #include "libbb.h" |
| 60 | #include "xregex.h" | 61 | #include "xregex.h" |
| @@ -64,7 +65,7 @@ | |||
| 64 | #define pkill (ENABLE_PKILL && (!ENABLE_PGREP || applet_name[1] == 'k')) | 65 | #define pkill (ENABLE_PKILL && (!ENABLE_PGREP || applet_name[1] == 'k')) |
| 65 | 66 | ||
| 66 | enum { | 67 | enum { |
| 67 | /* "vlafxons:+P:+" */ | 68 | /* "vlafxones:+P:+" */ |
| 68 | OPTBIT_V = 0, /* must be first, we need OPT_INVERT = 0/1 */ | 69 | OPTBIT_V = 0, /* must be first, we need OPT_INVERT = 0/1 */ |
| 69 | OPTBIT_L, | 70 | OPTBIT_L, |
| 70 | OPTBIT_A, | 71 | OPTBIT_A, |
| @@ -72,6 +73,7 @@ enum { | |||
| 72 | OPTBIT_X, | 73 | OPTBIT_X, |
| 73 | OPTBIT_O, | 74 | OPTBIT_O, |
| 74 | OPTBIT_N, | 75 | OPTBIT_N, |
| 76 | OPTBIT_E, /* should be pkill-only, do we care? */ | ||
| 75 | OPTBIT_S, | 77 | OPTBIT_S, |
| 76 | OPTBIT_P, | 78 | OPTBIT_P, |
| 77 | }; | 79 | }; |
| @@ -83,6 +85,7 @@ enum { | |||
| 83 | #define OPT_ANCHOR (opt & (1 << OPTBIT_X)) | 85 | #define OPT_ANCHOR (opt & (1 << OPTBIT_X)) |
| 84 | #define OPT_FIRST (opt & (1 << OPTBIT_O)) | 86 | #define OPT_FIRST (opt & (1 << OPTBIT_O)) |
| 85 | #define OPT_LAST (opt & (1 << OPTBIT_N)) | 87 | #define OPT_LAST (opt & (1 << OPTBIT_N)) |
| 88 | #define OPT_ECHO (opt & (1 << OPTBIT_E)) | ||
| 86 | #define OPT_SID (opt & (1 << OPTBIT_S)) | 89 | #define OPT_SID (opt & (1 << OPTBIT_S)) |
| 87 | #define OPT_PPID (opt & (1 << OPTBIT_P)) | 90 | #define OPT_PPID (opt & (1 << OPTBIT_P)) |
| 88 | 91 | ||
| @@ -93,8 +96,12 @@ static void act(unsigned pid, char *cmd, int signo) | |||
| 93 | printf("%u %s\n", pid, cmd); | 96 | printf("%u %s\n", pid, cmd); |
| 94 | else | 97 | else |
| 95 | printf("%u\n", pid); | 98 | printf("%u\n", pid); |
| 96 | } else | 99 | } else { |
| 97 | kill(pid, signo); | 100 | kill(pid, signo); |
| 101 | if (option_mask32 & (1 << OPTBIT_E)) { | ||
| 102 | printf("%s killed (pid %u)\n", cmd, pid); | ||
| 103 | } | ||
| 104 | } | ||
| 98 | } | 105 | } |
| 99 | 106 | ||
| 100 | int pgrep_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 107 | int pgrep_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
| @@ -131,7 +138,7 @@ int pgrep_main(int argc UNUSED_PARAM, char **argv) | |||
| 131 | /* Parse remaining options */ | 138 | /* Parse remaining options */ |
| 132 | ppid2match = -1; | 139 | ppid2match = -1; |
| 133 | sid2match = -1; | 140 | sid2match = -1; |
| 134 | opt = getopt32(argv, "vlafxons:+P:+", &sid2match, &ppid2match); | 141 | opt = getopt32(argv, "vlafxones:+P:+", &sid2match, &ppid2match); |
| 135 | argv += optind; | 142 | argv += optind; |
| 136 | 143 | ||
| 137 | if (pkill && OPT_LIST) { /* -l: print the whole signal list */ | 144 | if (pkill && OPT_LIST) { /* -l: print the whole signal list */ |
