I'm using gnuplot from the latest CVS source on macOS, NetBSD, and
Linux.
Gnuplot (with x11 terminal) does not suspend by Control-z when it is
configured with --with-readline=gnu; it requires any succeeding input
after Control-z to suspend.
When SIGTSTP is received, the signal handler of readline sets a flag
and just returns. Routines of readline check this flag to invoke the
real handler to suspend. Since we replace rl_getc_function by our own
routine to catch input from mouse, we should also check this flag to
invoke the real handler. Othewise, we cannot suspend until next time
routines of readline are used.
Unfortunately, there is no portable ways to invoke the real handler of
readline at the moment. We need to use its internal routine. They will
implement a public function for this purpose in their future releases:
http://lists.gnu.org/archive/html/bug-readline/2017-11/msg00021.html
Please find the attached patch for the latest CVS source as of today.
Thanks,
Rin Okuyama
The same problem must exist for each of gnuplot's interactive terminals, right? So either we would need to patch all of caca win x11 wxt qt (others?) equivalently or else find a solution that catches all of them together. Would it be possible for gnuplot to set up its own signal handler for SIGTSTP during program initialization and have that handler deal with the readline bookkeeping? That would resolve the issue for all terminal types, not just x11.
I have extracted the core code of your patch into a separate routine wrap_readline_signal_handler() so that it can be shared by multiple gnuplot terminals. The attached modified patch implements this change for the x11 wxt and qt terminals. The patch is against current git gnuplot-main tip. Please have a look.
Thank you for improving my patch (also thanks for forwarding message to my mail address).
I've confirmed it works fine for me with x11.
These few days, I was considering about your first proposal on implementation of its own signal
handler to gnuplot. However, I found it not so easy; term->waitforinput is called from readline
routines, and readline has its own signal handlers. I therefore think it is a good choice to wrap
signal handling stuffs into a separate function and share it from multiple terminals.
Let me thank you again for your kind response!
rin
Last edit: Rin Okuyama 2017-12-28
Notes:
Invoking the new wrapper routine from caca.trm does not seem to work.