bug-bash
[Top][All Lists]
Advanced

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

Re: [BUG] Bash not reacting to Ctrl-C


From: Chet Ramey
Subject: Re: [BUG] Bash not reacting to Ctrl-C
Date: Mon, 07 Mar 2011 19:29:45 -0500
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7

On 3/7/11 12:42 PM, Oleg Nesterov wrote:
> On 03/07, Chet Ramey wrote:
>>
>>> On 03/07, Chet Ramey wrote:
>>>>
>>>> *** 3090,3096 ****
>>>> --- 3099,3107 ----
>>>>      waitpid_flags |= WNOHANG;
>>>>    }
>>>>
>>>> +       waiting_for_child++;
>>>>         pid = WAITPID (-1, &status, waitpid_flags);
>>>
>>> OK, and what if ^C comes before waiting_for_child++ ?
>>>
>>> IIUC, in this case bash exits and leaves the current application
>>> (say, emacs which threats SIGINT specially) alone, no?
>>
>> Yes, it does.  However, the same problem exists now.  There is a window
>> between the time bash forks, the child execs, and bash waits when a SIGINT
>> can arrive and the same thing will happen.
> 
> OK... I seem to understand.... make_child() blocks SIGINT, but at this
> point the signal handler is SIG_DFL. And then it forks and unblocks the
> signal without installing the handler.
> 
> Thanks. I am just curious, is this another bug/problem or this was
> intended?

Intended.  The SIGINT gets blocked so the internal state doesn't get
messed up (and we want the fork to complete).  The wait signal handler
is only for when we're actually waiting for the child.  (And it's not
always SIGDFL -- this same code path is executed by interactive shells,
too.)

While it is a race condition, this one's really, really hard to hit.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

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