bug-readline
[Top][All Lists]
Advanced

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

[Bug-readline] documentation of signal handling


From: frederik
Subject: [Bug-readline] documentation of signal handling
Date: Mon, 25 Apr 2016 11:59:26 -0700
User-agent: Mutt/1.6.0 (2016-04-01)

Dear Readline people (and Chet Ramey),

I'm trying to help fix some bugs in the R interpreter, involving
signals not being received by GNU Readline.

R currently has problems which stem from ignoring SIGWINCH
<https://bugs.r-project.org/bugzilla/show_bug.cgi?id=16604>, and
failing to correctly reset the Readline state upon receiving SIGINT
<https://bugs.r-project.org/bugzilla/show_bug.cgi?id=16603>.

I understand from reading about a similar bug in Python
<https://bugs.python.org/issue23735> that the problem may stem from
signal handling changes made in Readline 6.3.

According to the Python bug (which quotes Chet), the solution is for
the application itself to trap SIGWINCH, and then set a flag to call
"rl_resize_terminal()" before the next "select()".

However, the need to do this is apparently not yet noted in the
Readline documentation, for instance the "Alternate interface example"
<http://cnswww.cns.cwru.edu/php/chet/readline/readline.html#SEC43>
seems to lack the extra code for SIGWINCH (and, presumably, SIGINT).

Delving a bit deeper, I'm wondering why it was necessary for Readline
to make application writers do all this extra work. For instance, why
not go back to installing signal handlers (via "rl_set_signals()") in
"rl_callback_handler_install()", and extend the callback interface
with a function - e.g. "rl_check_for_signal()" - that queries
_rl_caught_signal to see if a signal is pending? Then ask application
writers to call this function before/after "select()":

    while(running) {
      ...
      r = select (FD_SETSIZE, &fds, NULL, NULL, NULL);
      if (r < 0 && errno != EINTR) {
         /* Handle possible errors */
      }
      rl_check_for_signal(); /* <--- the new function */
      if (FD_ISSET (fileno (rl_instream), &fds))
        rl_callback_read_char ();
    }

This way python, gdb, R, etc. would only need a one-line change.
Wouldn't this be simpler than asking everyone to install their own
SIGINT and SIGWINCH handlers manually?

Sorry for the delay, I know Chet asked for "Thoughts?" in 2011...
<https://lists.gnu.org/archive/html/bug-readline/2011-07/msg00012.html>

Thank you,

Frederick Eaton





reply via email to

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