bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SIGTERM ignored before exec race


From: Pádraig Brady
Subject: SIGTERM ignored before exec race
Date: Sat, 09 Feb 2013 05:02:18 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1

$ 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

[Prev in Thread] Current Thread [Next in Thread]