bug-readline
[Top][All Lists]
Advanced

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

Re: Use of rl_echo_signal_char in _rl_handle_signal


From: Chet Ramey
Subject: Re: Use of rl_echo_signal_char in _rl_handle_signal
Date: Mon, 12 Jun 2023 11:33:52 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.11.2

On 6/7/23 8:52 AM, Andrew Burgess wrote:

I did some experimentation at my end and updated my sample program to
make use of rl_persistent_signal_handlers.  I agree with your first
suggestion, having the rl_echo_signal_char call conditional on
rl_persistent_signal_handlers (when in CALLBACK mode) seems to allow for
both options.

OK, this is a good start. It's missing several cases, so let's see if we
can tighten it up.


     In callback mode when rl_persistent_signal_handlers is on then the
     readline signal handler is always in place for the duration of the
     readline prompt being in use.  In this case it does make sense to
     always call rl_echo_signal_char.  By the time the application's signal
     handler is invoked we are on the way out of readline, and it is no
     longer the applications job to call rl_echo_signal_char.
In non-callback mode, this patch changes nothing, rl_echo_signal_char
     is always called.

These paragraphs are not correct. It's common practice to install a
readline library that was compiled with READLINE_CALLBACKS defined as the
standard readline library. I'm pretty sure Red Hat does it, for example.
The idea is that callbacks won't be active unless the application calls
rl_callback_handler_install().

This patch makes the call to rl_echo_signal_char() dependent on the setting
of rl_persistent_signal_handlers, which an application *not* using callback
mode will never set.

That test needs to be augmented with a condition that won't be true unless
callback mode is actually active. You should be able to test
RL_STATE_CALLBACK using RL_ISSTATE(), but you might also want to test
whether rl_linefunc is non-null. Let me know what works for you.

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]