summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1998-05-13 06:50:15 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1998-05-13 06:50:15 +0000
commitdca8f862a581af6d3517654e842a1d8742ab8361 (patch)
tree18c52093790c60669212b818dfef8d8049a00d7d /bin
parentc0d0d800bb5bf31bf880969f954658110df27f06 (diff)
support POSIX "kill [-s signame] pid" syntax, fix the "kill -l [exitstatus]"
syntax, sync documentation, no longer permit of full signal names in the "kill [-sig] pid" syntax, e.g. -SIGHUP; kleink
Diffstat (limited to 'bin')
-rw-r--r--bin/csh/csh.115
-rw-r--r--bin/csh/proc.c46
2 files changed, 45 insertions, 16 deletions
diff --git a/bin/csh/csh.1 b/bin/csh/csh.1
index 179f5e11394..bef0f4cedd1 100644
--- a/bin/csh/csh.1
+++ b/bin/csh/csh.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: csh.1,v 1.7 1997/11/17 06:55:49 deraadt Exp $
+.\" $OpenBSD: csh.1,v 1.8 1998/05/13 06:50:12 deraadt Exp $
.\" $NetBSD: csh.1,v 1.10 1995/03/21 09:02:35 cgd Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
@@ -1325,15 +1325,20 @@ Lists the active jobs; the
option lists process id's in addition to the normal information.
.Pp
.It Ic kill % Ns Ar job
-.It Ic kill Ar pid
+.It Ic kill
+.Op Fl s Ar signal_name
+.Ar pid
.It Ic kill Fl sig Ar pid ...
-.It Ic kill Fl l
+.It Ic kill Fl l Op exit_status
Sends either the TERM (terminate) signal or the
specified signal to the specified jobs or processes.
Signals are either given by number or by names (as given in
-.Pa /usr/include/signal.h,
+.Aq Pa signal.h ,
stripped of the prefix ``SIG'').
-The signal names are listed by ``kill \-l''.
+The signal names are listed by ``kill \-l'';
+if an
+.Ar exit_status
+is specified, only the corresponding signal name will be written.
There is no default, just saying `kill' does not
send a signal to the current job.
If the signal being sent is TERM (terminate) or HUP (hangup),
diff --git a/bin/csh/proc.c b/bin/csh/proc.c
index 7729c8ba7f7..b6c126b128b 100644
--- a/bin/csh/proc.c
+++ b/bin/csh/proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.c,v 1.7 1997/09/22 05:09:15 millert Exp $ */
+/* $OpenBSD: proc.c,v 1.8 1998/05/13 06:50:14 deraadt Exp $ */
/* $NetBSD: proc.c,v 1.9 1995/04/29 23:21:33 mycroft Exp $ */
/*-
@@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)proc.c 8.1 (Berkeley) 5/31/93";
#else
-static char rcsid[] = "$OpenBSD: proc.c,v 1.7 1997/09/22 05:09:15 millert Exp $";
+static char rcsid[] = "$OpenBSD: proc.c,v 1.8 1998/05/13 06:50:14 deraadt Exp $";
#endif
#endif /* not lint */
@@ -981,10 +981,23 @@ dokill(v, t)
v++;
if (v[0] && v[0][0] == '-') {
if (v[0][1] == 'l') {
- for (signum = 1; signum < NSIG; signum++) {
- (void) fprintf(cshout, "%s ", sys_signame[signum]);
- if (signum == NSIG / 2)
- (void) fputc('\n', cshout);
+ if (v[1]) {
+ if (!Isdigit(v[1][0]))
+ stderror(ERR_NAME | ERR_BADSIG);
+
+ signum = atoi(short2str(v[1]));
+ if (signum < 0 || signum >= NSIG)
+ stderror(ERR_NAME | ERR_BADSIG);
+ else if (signum == 0)
+ (void) fputc('0', cshout); /* 0's symbolic name is '0' */
+ else
+ (void) fprintf(cshout, "%s ", sys_signame[signum]);
+ } else {
+ for (signum = 1; signum < NSIG; signum++) {
+ (void) fprintf(cshout, "%s ", sys_signame[signum]);
+ if (signum == NSIG / 2)
+ (void) fputc('\n', cshout);
+ }
}
(void) fputc('\n', cshout);
return;
@@ -995,17 +1008,28 @@ dokill(v, t)
stderror(ERR_NAME | ERR_BADSIG);
}
else {
- name = short2str(&v[0][1]);
- if (!strncasecmp(name, "sig", 3))
- name += 3;
+ if (v[0][1] == 's' && (Isspace(v[0][2]) || v[0][2] == '\0'))
+ v++;
+ else
+ (*v)++;
+
+ if (v[0] == NULL || v[1] == NULL) {
+ stderror(ERR_NAME | ERR_TOOFEW);
+ return;
+ }
+ name = short2str(&v[0][0]);
for (signum = 1; signum < NSIG; signum++)
if (!strcasecmp(sys_signame[signum], name))
break;
if (signum == NSIG) {
- setname(vis_str(&v[0][1]));
- stderror(ERR_NAME | ERR_UNKSIG);
+ if (v[0][0] == '0')
+ signum = 0;
+ else {
+ setname(vis_str(&v[0][0]));
+ stderror(ERR_NAME | ERR_UNKSIG);
+ }
}
}
v++;