[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 09:38:18 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 |
On 4/6/18 8:03 PM, john smith wrote:
>> First of all, bash ignores SIGTERM when it's interactive, so if you don't
>> happen to send SIGTERM while readline is reading a command, you're not
>> going to get anything. (There is a recent post on bug-bash explaining why
>> readline returns EOF when it gets SIGTERM.)
>
> Thanks, you helped me understand something. I discovered that the
> above program would logout the current session I ran it in if I ran it
> in the background from another program like that:
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
>
> int main(void)
> {
> if(fork() == 0)
> {
> execv("/bin/kill-mine", NULL);
> }
> }
>
> Or put daemon() at the top:
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <signal.h>
> #include <unistd.h>
>
> int main(void)
> {
> daemon(0, 0);
> kill(-1, SIGTERM);
>
> return EXIT_SUCCESS;
> }
>
> Or simply run it with &:
>
> $ kill-mine &
>
> So the general conclusion is that it has be detached from the terminal
> before sending SIGTERM to bash. I still don't know answers for 2
> questions:
>
> 1. Where is the above checked in bash?
Sorry, the above what?
> 2. Why does busybox reboot make bash logout occasionally even if it
> theoretically shouldn't because it does not detach from terminal?
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).
--
``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/
- [Help-bash] readline does not always handle SIGTERM on reboot, john smith, 2018/04/06
- Re: [Help-bash] readline does not always handle SIGTERM on reboot, Chet Ramey, 2018/04/06
- Re: [Help-bash] readline does not always handle SIGTERM on reboot, john smith, 2018/04/06
- Re: [Help-bash] readline does not always handle SIGTERM on reboot, Chet Ramey, 2018/04/06
- Re: [Help-bash] readline does not always handle SIGTERM on reboot, john smith, 2018/04/06
- Message not available
- Message not available
- Re: [Help-bash] readline does not always handle SIGTERM on reboot, john smith, 2018/04/06
- Re: [Help-bash] readline does not always handle SIGTERM on reboot, john smith, 2018/04/07
- Re: [Help-bash] readline does not always handle SIGTERM on reboot, Chet Ramey, 2018/04/09
- Re: [Help-bash] readline does not always handle SIGTERM on reboot,
Chet Ramey <=
- Re: [Help-bash] readline does not always handle SIGTERM on reboot, john smith, 2018/04/09
- Re: [Help-bash] readline does not always handle SIGTERM on reboot, Chet Ramey, 2018/04/09
- Re: [Help-bash] readline does not always handle SIGTERM on reboot, john smith, 2018/04/09
- Re: [Help-bash] readline does not always handle SIGTERM on reboot, Chet Ramey, 2018/04/09