about summary refs log tree commit diff
path: root/Src/jobs.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/jobs.c')
-rw-r--r--Src/jobs.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/Src/jobs.c b/Src/jobs.c
index f3519ae2c..fc3737fa9 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -1504,20 +1504,29 @@ bin_kill(char *nam, char **argv, char *ops, int func)
     	    if ((*argv)[1] == 'n' && (*argv)[2] == '\0') {
 	    	char *endp;
 
-	    	sig = zstrtol(*++argv, &endp, 10);
+	    	if (!*++argv) {
+		    zwarnnam(nam, "-n: argument expected", NULL, 0);
+		    return 1;
+		}
+		sig = zstrtol(*argv, &endp, 10);
 		if (*endp) {
 		    zwarnnam(nam, "invalid signal number", signame, 0);
 		    return 1;
 		}
 	    } else {
-		if ((*argv)[1] == 's' && (*argv)[2] == '\0')
-		    signame = *++argv;
-		else
+		if (!((*argv)[1] == 's' && (*argv)[2] == '\0'))
 		    signame = *argv + 1;
+		else if (!(*++argv)) {
+		    zwarnnam(nam, "-s: argument expected", NULL, 0);
+		    return 1;
+		} else
+		    signame = *argv;
+		makeuppercase(&signame);
+		if (!strncmp(signame, "SIG", 3)) signame+=3;
 
 		/* check for signal matching specified name */
 		for (sig = 1; sig <= SIGCOUNT; sig++)
-		    if (!cstrpcmp(sigs + sig, &signame))
+		    if (!strcmp(*(sigs + sig), signame))
 			break;
 		if (*signame == '0' && !signame[1])
 		    sig = 0;
@@ -1531,6 +1540,11 @@ bin_kill(char *nam, char **argv, char *ops, int func)
 	argv++;
     }
 
+    if (!*argv) {
+    	zwarnnam(nam, "not enough arguments", NULL, 0);
+	return 1;
+    }
+
     queue_signals();
     setcurjob();