On 7/7/11 8:10 AM, I wrote:

>> I do not know if it is possible to code _rl_handle_signal in a way which uses
>> only the safe syscalls and only atomic operations on volatile data 
>> structures.
>> Anyway even if it would be possible I find such code very fragile and
>> I believe the signals should be always delayed through _rl_caught_signal.
> 
> Ironically, I changed it to respond immediately to signals when in callback
> mode because of a bug you filed from gdb.  When readline was reading input
> using rl_callback_read_char it did not respond quickly enough to SIGINT,
> and gdb didn't catch it.  You will have to check and make sure the
> conditions have changed enough to make it acceptable to delay signal
> handling.

It occurs to me that this will not work unless I make changes to readline's
callback implementation.  Currently readline installs its signal handlers
as part of the callback setup (rl_callback_handler_install ->
_rl_callback_newline).  This results in a situation where readline's signal
handlers are active when the application has flow control.  I imagine the
most likely scenario is that the application (gdb) is in a select() call
waiting for input when the signal arrives, readline sets a flag, and the
select call either restarts or returns -1/EINTR.  Either way, gdb can't do
anything about it except guess.

The most straightforward solution would be to move the signal setup into
rl_callback_read_char, so readline's signal handlers are in place only
when readline has control.  It's still important that the application
call rl_callback_handler_remove to restore the original signal handlers.

Once that's done, readline will not have to call signal handlers
synchronously when running in callback mode.  Thoughts?

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    [email protected]    http://cnswww.cns.cwru.edu/~chet/

_______________________________________________
Bug-readline mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-readline

Reply via email to