If I run, say time sleep 1000
in the shell, and send the time
process a SIGINT, it does not die.
So my question: If I run a program like this, how can I kill it from another program, assuming that I know the PID of the time
process that owns sleep
?
EDIT: Of course, sending SIGTERM will kill time
. But it will leave a dangling sleep
process.
EDIT: to reproduce the problem, run
/usr/bin/time sleep 1000 &
pid=$!
sleep 3
kill -INT $pid
This will not kill time
.
$!
gives the pid of your last command, so doing zsh -c "time sleep 1000" &
you do not get the pid of sleep and then kill -INT $pid
is not sent to sleep.
From your comment I don't have the PID of sleep, only of zsh (or time), you can access to the pid of sleep looking at the content of the file /proc/$pid/task/$pid/children
, then
kill -INT `cat /proc/$pid/task/$pid/children`
will do the job