From: Craig Small Date: Mon, 10 Sep 2018 12:41:45 +0000 (+1000) Subject: killall: ignore -n 0 X-Git-Tag: v23.2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2f431e49e168d935e7180d30996cdbaa7af3ef2d;p=psmisc killall: ignore -n 0 While all namespaces are used by default, this means if someone used the temporary -n 0 option in killall they will now get an error. We just silently ignore it References: commit 38829585c4f5b67c8c2a8cbdf86761a72ace43f6 psmisc/psmisc#15 --- diff --git a/ChangeLog b/ChangeLog index 903503b..350d1ec 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ Changes in 23.2 * killall: look at all namespaces by default * killall: Fix -INT option parsing #11 * killall: change to getopt_long without _only #12 + * killall: ignore -n 0 #15 * peekfd: Attach to all threads option !15 * pslog: Define PATH_MAX if required Debian:#905797 diff --git a/src/killall.c b/src/killall.c index 7f982a1..64c406a 100644 --- a/src/killall.c +++ b/src/killall.c @@ -859,7 +859,7 @@ main (int argc, char **argv) #ifdef WITH_SELINUX while ( (optc = getopt_long(argc,argv,"egy:o:ilqrs:u:vwZ:VIn:",options,NULL)) != -1) { #else - while ( (optc = getopt_long(argc,argv,"egy:o:ilqrs:u:vwVIn:",options,NULL)) != -1) { + while ( (optc = getopt_long_only(argc,argv,"egy:o:ilqrs:u:vwVIn:",options,NULL)) != -1) { #endif switch (optc) { case 'e': @@ -925,10 +925,15 @@ main (int argc, char **argv) } sig_num = get_signal (argv[optind]+1, "killall"); break; - case 'n': - opt_ns_pid = atoi(optarg); - if (opt_ns_pid == 0) + case 'n': { + long num; + char *end = NULL; + errno = 0; + num = strtol(optarg, &end, 10); + if (errno != 0 || optarg == end || end == NULL) usage(_("Invalid namespace PID")); + opt_ns_pid = (pid_t) num; + } break; #ifdef WITH_SELINUX case 'Z':