help-bash
[Top][All Lists]
Advanced

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

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


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

Didn't send this one to the list.
--- Begin Message --- Subject: Re: [Help-bash] readline does not always handle SIGTERM on reboot Date: Fri, 6 Apr 2018 14:53:16 -0400 User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.7.0
On 4/6/18 12:03 PM, john smith wrote:

>> Then readline is not active when the SIGTERM arrives, or its signal
>> handlers are not installed.
> 
> Hmm, maybe I don't understand something.  I wrote the following tiny
> program that does the same as busybox init:
> 
> #include <stdio.h>
> #include <stdlib.h>
> #include <sys/types.h>
> #include <signal.h>
> #include <unistd.h>
> #include <sys/reboot.h>
> 
> int main(void)
> {
>     kill(-1, SIGTERM);
> 
>     return EXIT_SUCCESS;
> }
> 
> If I run it in the ttyS0 serial console I also can't see `logout'
> string and other debug messages I added to rl_getc() what means that
> readline does not handle SIGTERM. 

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.)

The program you wrote will send SIGTERM to all processes owned by your
uid (I assume you're not running it as root), so if the bash process in
question is running as you, it should get the signal.

If you don't see the messages you've added to rl_getc, that does not mean
readline does not "handle" SIGTERM. Either bash does not receive SIGTERM
while readline is active, the SIGTERM does not interrupt the read(2), or
the EOF readline returns is not handled correctly.

If you want to see whether bash is receiving SIGTERM, watch it with a
system call tracer and see what happens when you run the program. If you
confirm that SIGTERM is received and want to see whether readline is active
when it is, put a debug message into rl_signal_handler and see if it gets
invoked.

-- 
``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/

--- End Message ---

reply via email to

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