Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

patch for kill builtin



We had a bug report saying that "kill -9hello <pid>" simply killed <pid>
with SIGKILL, rather than reporting that "9hello" wasn't a proper signal
name like bash and ksh do.  Since there's already code later on in
bin_kill() that recognizes this situation when you use -n, it was pretty
straightforward to copy the the code where -<number> was handled.

--- zsh-4.3.17/Src/jobs.c       Sat Dec 10 14:40:56 2011
+++ zsh-4.3.17/Src/jobs.c       Sat May 19 23:24:16 2012
@@ -2157,9 +2157,15 @@
 
     /* check for, and interpret, a signal specifier */
     if (*argv && **argv == '-') {
-       if (idigit((*argv)[1]))
+       if (idigit((*argv)[1])) {
+           char *endp;
            /* signal specified by number */
-           sig = atoi(*argv + 1);
+           sig = zstrtol(*argv + 1, &endp, 10);
+           if (*endp) {
+               zwarnnam(nam, "invalid signal number: %s", *argv);
+               return 1;
+           }
+       }
        else if ((*argv)[1] != '-' || (*argv)[2]) {
            char *signame;
 
Thanks,
Danek



Messages sorted by: Reverse Date, Date, Thread, Author