$ rpm -q kernel glibc bash
kernel-2.6.40.4-5.fc15.x86_64
glibc-2.14.1-6.x86_64
bash-4.2.10-4.fc15.x86_64

I notice the following will wait for 5 seconds for
the timeout process to end with SIGALRM, rather than
immediately due to kill sending the SIGTERM.

$ timeout 5 sleep 10& pid=$!; echo $pid >&2; kill $pid; wait
[1] 4895
4895
[1]+  Exit 124                timeout 5 sleep 10

If you put a small sleep in, the race is avoided, and SIGTERM
is sent to the timeout process.

$ timeout 5 sleep 10& pid=$!; echo $pid >&2; sleep .1; kill $pid; wait
[1] 4935
4935
[1]+  Exit 143                timeout 5 sleep 10

I tried dash and ksh and they don't exhibit the
behavior where SIGTERM is ignored. You can see here
that the shell is terminating before timeout is execd

dash$ timeout 5 sleep 10& pid=$!; echo $pid >&2; kill $pid; wait
5088
[1] + Terminated                 timeout 5 sleep 10

thanks,
Pádraig.

Reply via email to