Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Sep 2012 11:22:23 -0700
From:      Garrett Cooper <yanegomi@gmail.com>
To:        John Baldwin <jhb@freebsd.org>
Cc:        arch@freebsd.org
Subject:   Re: [PATCH] Close a race between exit1() and SIGSTOP
Message-ID:  <CAGH67wSdWWFVSwW43NNGzTxjkYm_MTtynosT4N-REH3it1jT0g@mail.gmail.com>
In-Reply-To: <201209071416.24970.jhb@freebsd.org>
References:  <201209071217.47439.jhb@freebsd.org> <CAGH67wRu91eOmB-cxWOkVDvLPZ-BpLs=GuYhwwbD9s697xpkFA@mail.gmail.com> <201209071416.24970.jhb@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Sep 7, 2012 at 11:16 AM, John Baldwin <jhb@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGH67wSdWWFVSwW43NNGzTxjkYm_MTtynosT4N-REH3it1jT0g>