bug-readline
[Top][All Lists]
Advanced

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

Re: pending signal after rl_callback_read_char


From: Chet Ramey
Subject: Re: pending signal after rl_callback_read_char
Date: Wed, 21 Sep 2022 10:04:00 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.2.2

On 9/20/22 4:17 PM, Simon Marchi wrote:

In the meantime, you could look at rl_persistent_signal_handlers,
which, in theory, should work on readline versions >= 7.0.

Ok, however GDB has its own signal handlers that it relies on, so I'm
not sure how it would work if readline's handlers were installed all the
time.

"All the time" means from the time readline prints a prompt until it
executes rl_accept_line or otherwise sets rl_done, presumably over a series
of calls to rl_callback_read_char(). It's the equivalent of having readline's signal handlers installed for the duration of a call to
readline().

The default is to have the signal handlers installed only for the duration
of a call to rl_callback_read_char().

Readline's signal handler calls any application-installed handler (well,
it resets the signal dispositions and resends the signal). That's how gdb's
SIGINT handler gets called when readline's signal handlers are installed.


Just a note, earlier you said that GDB is using readline without any
callback and that it blocks into rl_callback_read_char, I don't think
that's true.  We have an event loop and only call into readline when
input is available.

You haven't executed a readline command that would cause a function pointer to be assigned to _rl_callback_func (private and internal). That's another code path that executes _rl_internal_char_cleanup() (there are several).


So, I'm not entirely sure how things work when you are sitting at the
GDB prompt and press ^C.  Does readline get involved at all in that
case?

If readline is in the middle of a call to rl_callback_read_char, then yes.
If not, then no.

What are readline signals useful for?

Readline changes the terminal settings and other user state, and allocates
per-call memory and other resources, and has to catch signals so it can
clean that up.

I see we can also disable
readline's signal handling (set rl_catch_signals to 0), I'm wondering if
that would work for us.

Sure, if you want to do all that work for yourself.

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




reply via email to

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