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 09:41:11 -0400
User-agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.7.0
On 4/7/18 6:03 PM, john smith wrote:
> I discovered that I can kill current session of bash with the following:
>
> (sleep 1; kill $$) &
>
> Only in such situation is rl_signal_handler() called, errno is set to
> EINTR in rl_getc() and EOF is returned. I just don't understand why
> rl_signal_handler() is not called when this is done:
>
> kill $$
Because readline's signal handlers are not installed when the calling
application is not making a call to readline().
Think about what happens when you run this. You hit return, readline
uninstalls its signal handlers and returns "kill $$" to bash, the calling
application. Bash takes that command and runs it, waiting for the command
to complete and collecting its return status. The command causes a signal
to be sent, which is handled by the bash SIGTERM signal handler.
--
``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/