[PATCH] Close a race between exit1() and SIGSTOP
John Baldwin
jhb at freebsd.org
Fri Sep 7 18:19:23 UTC 2012
On Friday, September 07, 2012 12:35:52 pm Garrett Cooper wrote:
> Does this case continue to function normally?
>
> $ sh -c 'while :; do sleep 1; done'
> ^Z
> [1]+ Stopped sh -c 'while :; do sleep 1; done'
> $ kill %1
> $ fg
> bash: fg: job has terminated
> [1]+ Terminated: 15 sh -c 'while :; do sleep 1; done'
>
> $ sh -c 'while :; do sleep 1; done'
> ^Z
> [1]+ Stopped sh -c 'while :; do sleep 1; done'
> $ kill %1
> $ kill %1
> bash: kill: (3522) - No such process
> [1]+ Terminated: 15 sh -c 'while :; do sleep 1; done'
>
> In particular, a single kill results in the signal being sent after
> the process wakes up, and a double kill results in the immediate death
> of the process (in this case a shell job) (in part because of the
> signals /bin/sh masks).
This still works in bash:
> bash
$ sh -c 'while :; do sleep 1; done'
^Z
[1]+ Stopped sh -c 'while :; do sleep 1; done'
$ kill %1
$ fg
bash: fg: job has terminated
[1]+ Terminated: 15 sh -c 'while :; do sleep 1; done'
$ sh -c 'while :; do sleep 1; done'
^Z
[1]+ Stopped sh -c 'while :; do sleep 1; done'
$ kill %1
$ kill %1
bash: kill: (61009) - No such process
[1]+ Terminated: 15 sh -c 'while :; do sleep 1; done'
I get different behavior in tcsh:
> sh -c 'while :; do sleep 1; done'
^Z
Suspended
> kill %1
>
[1] Terminated sh -c while :; do sleep 1; done
Note that this patch merey inhibits SIGSTOP from having an effect while
a process is exiting, it does not affect SIGTERM at all, so I don't think
it could have any effect on this case anyway.
--
John Baldwin
More information about the freebsd-arch
mailing list