* kill builtin
@ 2001-12-21 3:26 Gerald Britton
2001-12-21 5:56 ` kill and _kill/_signals problems Geoff Wing
2001-12-21 16:17 ` kill builtin Oliver Kiddle
0 siblings, 2 replies; 4+ messages in thread
From: Gerald Britton @ 2001-12-21 3:26 UTC (permalink / raw)
To: zsh-workers
Discovered today that redhat's initscripts try to execute roughly:
$SHELL -c kill -SIGIO $PID
which works if root's shell is bash, the util-linux kill command also
accepts -SIG<SIG> args, however, zsh's kill builtin doesn't accept this.
it seems like a perfectly simple patch to do, and i'd probably do it myself
if it weren't for being behind a 14.4 cellular link at the moment (it was the
ppp-watch stuff in redhat's initscripts which tried to do that ;)
-- Gerald
^ permalink raw reply [flat|nested] 4+ messages in thread
* kill and _kill/_signals problems
2001-12-21 3:26 kill builtin Gerald Britton
@ 2001-12-21 5:56 ` Geoff Wing
2001-12-21 16:17 ` kill builtin Oliver Kiddle
1 sibling, 0 replies; 4+ messages in thread
From: Geoff Wing @ 2001-12-21 5:56 UTC (permalink / raw)
To: zsh-workers
Heyla,
kill problem:
% kill -n
<coredump> Missing a check for the argument:
#1 0x48091c03 in bin_kill (nam=0x805ad68 "kill", argv=0xbfbfd310,
ops=0xbfbfd364 "", func=0) at jobs.c:1507
1504 if ((*argv)[1] == 'n' && (*argv)[2] == '\0') {
1505 char *endp;
1506
1507 sig = zstrtol(*++argv, &endp, 10);
------------------------------------------------------------
_kill or _signals problem (for me):
% kill -SIG<TAB>
--> completing corrections
-IO -SEGV -SYS -URG
--> completing original
-SIG
% kill -IOEGV
Regards,
--
Geoff Wing
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: kill builtin
2001-12-21 3:26 kill builtin Gerald Britton
2001-12-21 5:56 ` kill and _kill/_signals problems Geoff Wing
@ 2001-12-21 16:17 ` Oliver Kiddle
2002-01-07 13:22 ` Sven Wischnowsky
1 sibling, 1 reply; 4+ messages in thread
From: Oliver Kiddle @ 2001-12-21 16:17 UTC (permalink / raw)
To: Gerald Britton; +Cc: zsh-workers
Gerald Britton wrote:
>
> Discovered today that redhat's initscripts try to execute roughly:
>
> $SHELL -c kill -SIGIO $PID
>
> which works if root's shell is bash, the util-linux kill command also
> accepts -SIG<SIG> args, however, zsh's kill builtin doesn't accept this.
> it seems like a perfectly simple patch to do, and i'd probably do it myself
> if it weren't for being behind a 14.4 cellular link at the moment (it was the
> ppp-watch stuff in redhat's initscripts which tried to do that ;)
Thanks for reporting this. The patch below adds that. We should
probably do the same for trap.
I seem to remember that strncasecmp isn't portable and we've not used
it elsewhere so I've used an uppercase conversion followed by strncmp.
As a result, it no longer uses a strcoll based comparison for finding
the signals. Anyone know if that was necessary (seemed a bit weird to
me)? For the trap builtin, strncasecmp would again be useful so it
might be better just to implement one.
Geoff Wing wrote:
>
> kill problem:
>
> % kill -n
> <coredump> Missing a check for the argument:
kill -s suffers the same problem so 4.0 also needs fixing. The easiest
might be if I just apply this and 16224 to 4.0 but if anyone objects I
can instead fix kill -s in 4.0.
I've also got it to print an error if no pids are specified.
> _kill or _signals problem (for me):
>
> % kill -SIG<TAB>
> --> completing corrections
> -IO -SEGV -SYS -URG
> --> completing original
> -SIG
> % kill -IOEGV
I get a similar problem (-SEGVEGV). I can't see anything wrong with
_signals so it seems to me to be _approximate/_correct.
Anyway, I'm now away till January. Have a good Christmas everyone.
Oliver
Index: Completion/Unix/Type/_signals
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_signals,v
retrieving revision 1.2
diff -u -r1.2 _signals
--- Completion/Unix/Type/_signals 2001/11/06 15:07:00 1.2
+++ Completion/Unix/Type/_signals 2001/12/21 15:48:24
@@ -21,9 +21,10 @@
if [[ -z "$minus" ]] ||
! zstyle -T ":completion:${curcontext}:signals" prefix-needed ||
- [[ "$PREFIX" = -* ]]; then
+ [[ -prefix -* ]]; then
local disp tmp
+ [[ -prefix ${minus}SIG* ]] && minus+=SIG
if zstyle -t ":completion:${curcontext}:signals" prefix-hidden; then
tmp=( "${(@)signals[1,last]}" )
disp=(-d tmp)
Index: Src/jobs.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/jobs.c,v
retrieving revision 1.14
diff -u -r1.14 jobs.c
--- Src/jobs.c 2001/11/06 15:07:00 1.14
+++ Src/jobs.c 2001/12/21 15:48:25
@@ -1504,20 +1504,29 @@
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;
@@ -1529,6 +1538,11 @@
}
}
argv++;
+ }
+
+ if (!*argv) {
+ zwarnnam(nam, "not enough arguments", NULL, 0);
+ return 1;
}
queue_signals();
_____________________________________________________________________
This message has been checked for all known viruses by the
MessageLabs Virus Scanning Service. For further information visit
http://www.messagelabs.com/stats.asp
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: kill builtin
2001-12-21 16:17 ` kill builtin Oliver Kiddle
@ 2002-01-07 13:22 ` Sven Wischnowsky
0 siblings, 0 replies; 4+ messages in thread
From: Sven Wischnowsky @ 2002-01-07 13:22 UTC (permalink / raw)
To: zsh-workers
Oliver Kiddle wrote:
> ...
>
> > _kill or _signals problem (for me):
> >
> > % kill -SIG<TAB>
> > --> completing corrections
> > -IO -SEGV -SYS -URG
> > --> completing original
> > -SIG
> > % kill -IOEGV
>
> I get a similar problem (-SEGVEGV). I can't see anything wrong with
> _signals so it seems to me to be _approximate/_correct.
Right, I've prepared a fix for that. The compadd function in
_approximate was seeing -SEGV and thought that was a group name option
to compadd, not looking at the `-' argument before it.
I also had prepared a fix for the other things you fixed, so I only
add the stuff I have which you haven't done.
The patch changes _signals to accept a -s option meaning that
SIG-prefixes are to be understood (since they probably aren't allowed
everywhere). It also removes the test in _kill (testing for -prefix [%0-9]#).
I know what that was supposed to do, but it made completion of pids by
command names fail, obviously. And finally, there is a bit of
documentation for the optional SIG prefix.
Bye
Sven
Index: Completion/Base/Completer/_approximate
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Completer/_approximate,v
retrieving revision 1.6
diff -u -r1.6 _approximate
--- Completion/Base/Completer/_approximate 2001/08/20 13:13:50 1.6
+++ Completion/Base/Completer/_approximate 2002/01/07 13:17:37
@@ -60,8 +60,8 @@
PREFIX="(#a${_comp_correct})$PREFIX"
fi
- (( $_correct_group && $argv[(I)-*[JV]] )) &&
- _correct_expl[_correct_group]=${argv[(R)-*[JV]]}
+ (( $_correct_group && ${${argv[1,(r)-(|-)]}[(I)-*[JV]]} )) &&
+ _correct_expl[_correct_group]=${argv[1,(r)-(-|)][(R)-*[JV]]}
builtin compadd "$_correct_expl[@]" "$@"
}
Index: Completion/Unix/Type/_signals
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Type/_signals,v
retrieving revision 1.3
diff -u -r1.3 _signals
--- Completion/Unix/Type/_signals 2001/12/21 16:33:39 1.3
+++ Completion/Unix/Type/_signals 2002/01/07 13:17:37
@@ -4,12 +4,13 @@
#
# -a use all signals (even the pseudo-signals)
# -p needs a `-' prefix
+# -s SIG prefix allowed
#
# A `-' or `--' as the first argument is ignored.
-local expl last minus
+local expl last minus pre sigs
-zparseopts -D -K -E 'p=minus' 'a=last'
+zparseopts -D -K -E 'p=minus' 'a=last' 's=pre'
if [[ -z "$last" ]]; then
last=-1
else
@@ -24,14 +25,21 @@
[[ -prefix -* ]]; then
local disp tmp
- [[ -prefix ${minus}SIG* ]] && minus+=SIG
if zstyle -t ":completion:${curcontext}:signals" prefix-hidden; then
tmp=( "${(@)signals[1,last]}" )
disp=(-d tmp)
else
disp=()
fi
+
+ if [[ -n "$pre" && $PREFIX = ${minus}S* ]]; then
+ sigs=( "${minus}SIG${(@)^signals[1,last]}" )
+ (( $#disp )) && tmp=( "$tmp[@]" "${(@)signals[1,last]}" )
+ else
+ sigs=()
+ fi
+
_wanted signals expl signal \
compadd "$@" "$disp[@]" -M 'm:{a-z}={A-Z}' - \
- "${minus}${(@)^signals[1,last]}"
+ "${minus}${(@)^signals[1,last]}" "$sigs[@]"
fi
Index: Completion/Zsh/Command/_kill
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Zsh/Command/_kill,v
retrieving revision 1.2
diff -u -r1.2 _kill
--- Completion/Zsh/Command/_kill 2001/11/06 15:07:00 1.2
+++ Completion/Zsh/Command/_kill 2002/01/07 13:17:37
@@ -4,12 +4,12 @@
_arguments -C \
'(-s -l 1)-n[specify signal number]:signal number' \
- '(-n -l 1)-s[specify signal name]:signal:_signals' \
+ '(-n -l 1)-s[specify signal name]:signal:_signals -s' \
'(-n -s)-l[list signal names or numbers of specified signals]:*:signal:_signals' \
- '(-n -s -l)1::signal:_signals -p' \
+ '(-n -s -l)1::signal:_signals -p -s' \
'*:processes:->processes' && ret=0
-if [[ -n "$state" && -prefix [%0-9]# ]]; then
+if [[ -n "$state" ]]; then
_alternative \
'processes:: _pids' \
'jobs:: _jobs -t' && ret=0
Index: Doc/Zsh/builtins.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v
retrieving revision 1.42
diff -u -r1.42 builtins.yo
--- Doc/Zsh/builtins.yo 2001/11/09 16:47:45 1.42
+++ Doc/Zsh/builtins.yo 2002/01/07 13:17:38
@@ -539,7 +539,8 @@
item(tt(kill) tt(-l) [ var(sig) ... ])(
Sends either tt(SIGTERM) or the specified signal to the given
jobs or processes.
-Signals are given by number or by names, without the `tt(SIG)' prefix.
+Signals are given by number or by names, with or without the `tt(SIG)'
+prefix.
If the signal being sent is not `tt(KILL)' or `tt(CONT)', then the job
will be sent a `tt(CONT)' signal if it is stopped.
The argument var(job) can be the process ID of a job
--
Sven Wischnowsky wischnow@berkom.de
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-01-07 13:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-21 3:26 kill builtin Gerald Britton
2001-12-21 5:56 ` kill and _kill/_signals problems Geoff Wing
2001-12-21 16:17 ` kill builtin Oliver Kiddle
2002-01-07 13:22 ` Sven Wischnowsky
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).