[PATCH] Close a race between exit1() and SIGSTOP

Garrett Cooper yanegomi at gmail.com
Fri Sep 7 18:22:30 UTC 2012


On Fri, Sep 7, 2012 at 11:16 AM, John Baldwin <jhb at freebsd.org> wrote:
> 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.

I should have said /bin/sh (I don't use tcsh by choice anymore because
of its fun bugs).

Good point.. I'd need to do more digging to better understand what is
trying to be resolved here.

Thanks!
-Garrett


More information about the freebsd-arch mailing list