mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-06-18 09:28:02 +02:00
52326, 52372: add -q option to kill for sigqueue
This commit is contained in:
parent
0394b7cf17
commit
618f842b46
5 changed files with 43 additions and 3 deletions
|
@ -1,5 +1,8 @@
|
|||
2023-12-05 Oliver Kiddle <opk@zsh.org>
|
||||
|
||||
* 52326, 52372: configure.ac, Src/jobs.c, Doc/Zsh/builtins.yo,
|
||||
Completion/Zsh/Command/_kill: add -q option to kill for sigqueue
|
||||
|
||||
* 52373: Completion/Base/Utility/_numbers,
|
||||
Completion/Solaris/Command/_dumpadm, Completion/Unix/Command/_xz:
|
||||
fix _numbers for suffixes containing % and update affected functions
|
||||
|
|
|
@ -5,6 +5,7 @@ typeset -A opt_args
|
|||
|
||||
_arguments -C \
|
||||
'(-s -l 1)-n[specify signal number]:signal number' \
|
||||
'(-l)-q[send the specified integer with the signal using sigqueue]:value' \
|
||||
'(-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 -s' \
|
||||
|
|
|
@ -1143,7 +1143,7 @@ findex(kill)
|
|||
cindex(killing jobs)
|
||||
cindex(jobs, killing)
|
||||
xitem(tt(kill) [ tt(-s) var(signal_name) | tt(-n) var(signal_number) | \
|
||||
tt(-)var(sig) ] var(job) ...)
|
||||
tt(-)var(sig) ] [ tt(-q) var(value) ] var(job) ...)
|
||||
item(tt(kill) tt(-l) [ var(sig) ... ])(
|
||||
Sends either tt(SIGTERM) or the specified signal to the given
|
||||
jobs or processes.
|
||||
|
@ -1170,6 +1170,9 @@ tt(kill -IO) and tt(kill -POLL) have the same effect.
|
|||
|
||||
Many systems will allow process IDs to be negative to kill a process
|
||||
group or zero to kill the current process group.
|
||||
|
||||
The tt(-q) option allows an integer value to be sent with the signal
|
||||
on systems that support tt(sigqueue+LPAR()RPAR()).
|
||||
)
|
||||
findex(let)
|
||||
item(tt(let) var(arg) ...)(
|
||||
|
|
36
Src/jobs.c
36
Src/jobs.c
|
@ -2677,9 +2677,35 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
|
|||
{
|
||||
int sig = SIGTERM;
|
||||
int returnval = 0;
|
||||
#ifdef HAVE_SIGQUEUE
|
||||
union sigval sigqueue_info;
|
||||
#endif
|
||||
int use_sigqueue = 0, got_sig = 0;
|
||||
|
||||
while (*argv && **argv == '-') {
|
||||
if (!use_sigqueue && (*argv)[1] == 'q' && (*argv)[2] == '\0') {
|
||||
char *endp;
|
||||
|
||||
if (!*++argv) {
|
||||
zwarnnam(nam, "-q: argument expected");
|
||||
return 1;
|
||||
}
|
||||
#ifdef HAVE_SIGQUEUE
|
||||
sigqueue_info.sival_int =
|
||||
#endif
|
||||
zstrtol(*argv, &endp, 10);
|
||||
if (*endp) {
|
||||
zwarnnam(nam, "invalid number: %s", *argv);
|
||||
return 1;
|
||||
}
|
||||
use_sigqueue = 1;
|
||||
argv++;
|
||||
continue;
|
||||
}
|
||||
if (got_sig)
|
||||
break;
|
||||
|
||||
/* check for, and interpret, a signal specifier */
|
||||
if (*argv && **argv == '-') {
|
||||
if (idigit((*argv)[1])) {
|
||||
char *endp;
|
||||
/* signal specified by number */
|
||||
|
@ -2796,6 +2822,7 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
|
|||
}
|
||||
}
|
||||
argv++;
|
||||
got_sig = 1;
|
||||
}
|
||||
|
||||
/* Discard the standard "-" and "--" option breaks */
|
||||
|
@ -2844,7 +2871,12 @@ bin_kill(char *nam, char **argv, UNUSED(Options ops), UNUSED(int func))
|
|||
returnval++;
|
||||
} else {
|
||||
int pid = atoi(*argv);
|
||||
if (kill(pid, sig) == -1) {
|
||||
if (
|
||||
#ifdef HAVE_SIGQUEUE
|
||||
use_sigqueue ? sigqueue(pid, sig, sigqueue_info) :
|
||||
#endif
|
||||
kill(pid, sig) == -1)
|
||||
{
|
||||
zwarnnam("kill", "kill %s failed: %e", *argv, errno);
|
||||
returnval++;
|
||||
}
|
||||
|
|
|
@ -1299,6 +1299,7 @@ AC_CHECK_FUNCS(strftime strptime mktime timelocal \
|
|||
mkfifo _mktemp mkstemp \
|
||||
waitpid wait3 \
|
||||
sigaction sigblock sighold sigrelse sigsetmask sigprocmask \
|
||||
sigqueue \
|
||||
killpg setpgid setpgrp tcsetpgrp tcgetattr nice \
|
||||
gethostname gethostbyname2 getipnodebyname \
|
||||
inet_aton inet_pton inet_ntop \
|
||||
|
|
Loading…
Reference in a new issue