help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] readline does not always handle SIGTERM on reboot


From: Chet Ramey
Subject: Re: [Help-bash] readline does not always handle SIGTERM on reboot
Date: Mon, 9 Apr 2018 15:01:59 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

On 4/9/18 2:56 PM, john smith wrote:
> On Mon, Apr 9, 2018 at 7:51 PM, Chet Ramey <address@hidden> wrote:
>> On 4/9/18 12:55 PM, john smith wrote:
>>
>>>> I don't run busybox, so I won't speculate. My first guess would be that
>>>> the signal comes in while bash is ignoring SIGTERM (by catching the signal
>>>> and discarding it).
>>>
>>> I've analyzed bash and readline during the weekend and I learned that
>>> readline() overwrites bash SIGTERM handler and restores it after it
>>> finishes, this is why `kill $$' does not kill the current session but
>>> `(sleep 1; kill $$) &' does.
>>
>> You left out the part where readline resends the signal to the calling
>> application, assuming the calling application hasn't set the signal
>> handler to SIG_IGN (in which case readline would not install a handler
>> for it at all).
> 
> Yes, I think I also got this.  I wondered why history is saved when I
> simply close my xterm window, now I know that readline() resends
> SIGHUP back to bash in _rl_handle_signal().

That's the same reason that bash catches, but discards, SIGTERM and allows
readline to return EOF.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    address@hidden    http://tiswww.cwru.edu/~chet/



reply via email to

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