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, 5 Jun 2023 16:34:11 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.11.2

On 6/1/23 6:40 AM, Andrew Burgess wrote:

This email originated as a conversation on the GDB list, which can be
found here:

   
https://inbox.sourceware.org/gdb-patches/20230518061046.17837-1-tdevries@suse.de/

The problem that was observed was that sometimes during testing GDB
would print '^C', but most of the time this would not happen.

The '^C' is printed from rl_echo_signal_char.

What normally happens is that the user types a character, GDB sees the
character appear on stdin and calls into readline to process the
character.  Once completed readline returns to GDB to await the next
event.  In this case the next event is the user typing 'Ctrl+c' which
sends SIGINT.  GDB's signal handler catches this and does its thing.

This works fine if the application supplies its own signal handlers, like
GDB does. There are lots of applications that use readline that don't, but
would still like to see the signal characters. These are usually the ones
that set rl_persistent_signal_handlers, but not always. Making the change
you suggest woul break those apps in an incompatible way, with no way to
get their desired behavior.

The documentation for rl_echo_signal_char says:

      If an application wishes to install its own signal handlers, but
      still have readline display characters that generate signals,
      calling this function with SIG set to 'SIGINT', 'SIGQUIT', or
      'SIGTSTP' will display the character generating that signal.

I would also make the assumption that, when readline is used in callback
mode, the application spends most of its time with the applications
signal handlers installed, and only installs readline's handlers
occasionally.

This is a good assumption for GDB, but not for other applications. Several
interactive python applications, for instance, don't install their own
signal handlers at all, and rely on readline's signal handlers entirely.

What do you suggest? Conditionalizing this behavior on whether or not
rl_persistent_signal_handlers is set? Having readline set a flag if it
prints the signal char info?

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]