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

next in thread | previous in thread | raw e-mail | index | archive | help
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



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