Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
kill %jobspec tries to kill dead processes
- X-seq: zsh-workers 42226
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: kill %jobspec tries to kill dead processes
- Date: Fri, 5 Jan 2018 12:46:02 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:mime-version :content-disposition:user-agent; bh=R3dsusCXLyoelvx4h4OVTHVnQgw6Vj77vdMIMI2Ap+s=; b=Jg8dMYuV2QhCrMcHmSezY5Yf0EmrH8y8sI/4ZQWSWyo/fFLv6BjSoOze02UShDE2nj N9Gl1ycIuob3LgEjWWe5+3smcPeN5ypY4alzTqUjzFuzH0jdCwwEeIsG8QPDR9CRKFYZ RsgUoODRsBidfUSZvJ6tP8jB1XzaCawQe8fhEH+nWg798fBUde0gT5JLDCuwrnbr8FZX ofaSHWSfiabO+00fGnZ1lxL65Sp6WdcUum9ympXb1n/0cQFKDVxZGG1wYnCsG1yTI7Mi Q0/lLKXc2BzAX660Nck9z2jh9Oo85oxgiBz7a4AaQRlZ3vmgOu9Eyb5GPP48BWJn9jap FARw==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
Hi,
kill %jobspec
usually avoids the problem when kill $pid may kill the wrong
process when it may have been reused. However, in:
sleep 1 | sleep 3 & sleep 2
kill %"sleep 1"
kill still tries to kill the process that was running sleep 1
even though the shell knows it has died:
$ strace -e kill zsh -c 'sleep 1 | sleep 3 & ps -f; sleep 2; printf "%s => %s\n" "${(@kv)jobstates}"; kill %"sleep 1"'
UID PID PPID C STIME TTY TIME CMD
chazelas 8175 14816 0 12:37 pts/4 00:00:00 strace -e kill zsh -c sleep 1 | sleep 3 & ps -f; sleep 2; printf "%s => %s\n" "${(@kv)jobstates}"; kill %"sleep 1"
chazelas 8177 8175 0 12:37 pts/4 00:00:00 zsh -c sleep 1 | sleep 3 & ps -f; sleep 2; printf "%s => %s\n" "${(@kv)jobstates}"; kill %"sleep 1"
chazelas 8178 8177 0 12:37 pts/4 00:00:00 sleep 1
chazelas 8179 8177 0 12:37 pts/4 00:00:00 sleep 3
chazelas 8180 8177 0 12:37 pts/4 00:00:00 ps -f
chazelas 14816 14812 0 Jan03 pts/4 00:00:01 /bin/zsh
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=8180, si_uid=1000, si_status=0, si_utime=0, si_stime=2} ---
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=8178, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=8181, si_uid=1000, si_status=0, si_utime=0, si_stime=0} ---
1 => running:+:8178=done:8179=running
kill(8178, SIGTERM) = -1 ESRCH (No such process)
kill(8179, SIGTERM) = 0
+++ exited with 0 +++
See how 8178 was known to be "done", but is still killed.
mksh has the same issue. bash is worse in that it doesn't
attempt to kill the sleep 3 process. ksh93 segfaults when I try
the same thing there.
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author