psmisc/psmisc-23.0-killall-signals.patch

88 lines
2.1 KiB
Diff
Raw Normal View History

--- src/killall.c 2017-07-06 16:23:15.693736411 +0200
+++ src/killall.c 2017-09-18 12:00:46.506409019 +0200
@@ -796,6 +796,18 @@ have_proc_self_stat (void)
return stat(filename, &isproc) == 0;
}
+typedef struct
+{
+ int number;
+ const char *sig;
+}
+SIGNAME;
+
+static SIGNAME signals[] = {
+#include "signames.h"
+ {0, NULL}
+};
+
int
main (int argc, char **argv)
{
@@ -807,7 +819,7 @@ main (int argc, char **argv)
char yt[16];
char ot[16];
- //int optsig = 0;
+ int optsig;
struct option options[] = {
{"exact", 0, NULL, 'e'},
@@ -828,6 +840,7 @@ main (int argc, char **argv)
{"context", 1, NULL, 'Z'},
#endif /*WITH_SELINUX*/
{"version", 0, NULL, 'V'},
+ {"dummy", 0, NULL, 'd'},
{0,0,0,0 }};
opt_ns_pid = getpid();
@@ -852,14 +865,46 @@ main (int argc, char **argv)
name = *argv;
sig_num = SIGTERM;
+ optsig = argc;
+ while (--optsig) {
+ char *sig;
+ size_t len;
+ if (*(argv[optsig]) != '-')
+ continue;
+ sig = argv[optsig]+1;
+ len = strlen(sig);
+ if (*sig >= '0' && *sig <= '9') {
+ sig_num = atoi (sig);
+ memset(sig, 0, strlen(sig));
+ *sig = 'd';
+ } else if (len >= 3 && *sig >= 'A' && *sig <= 'Z') {
+ SIGNAME *walk;
+ char *opt = sig;
+ if (!strncmp("SIG", sig, 3))
+ sig += 3;
+ for (walk = signals; walk->sig; walk++) {
+ if (!strcmp (walk->sig, sig))
+ break;
+ }
+ if (walk->sig) {
+ sig_num = walk->number;
+ memset(opt, 0, strlen(opt));
+ *opt = 'd';
+ break;
+ }
+ }
+ }
opterr = 0;
+ unsetenv("POSIXLY_CORRECT");
#ifdef WITH_SELINUX
- while ( (optc = getopt_long_only(argc,argv,"egy:o:ilqrs:u:vwZ:VIn:",options,NULL)) != -1) {
+ while ( (optc = getopt_long_only(argc,argv,"degy:o:ilqrs:u:vwZ:VIn:",options,NULL)) != -1) {
#else
- while ( (optc = getopt_long_only(argc,argv,"egy:o:ilqrs:u:vwVIn:",options,NULL)) != -1) {
+ while ( (optc = getopt_long_only(argc,argv,"degy:o:ilqrs:u:vwVIn:",options,NULL)) != -1) {
#endif
switch (optc) {
+ case 'd':
+ break;
case 'e':
exact = 1;
break;