|
From: | Rin Okuyama |
Subject: | Re: [Bug-readline] [PATCH] Gnuplot on macOS does not suspend by Control-z |
Date: | Tue, 28 Nov 2017 23:20:29 +0900 |
User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 |
On 2017/11/28 3:03, Chet Ramey wrote:
On 11/26/17 8:43 AM, Rin Okuyama wrote:
...
(1) _rl_signal_handler() is used as before: ---- int getc_wrapper(FILE *fp) { fd_set fds; int fd = fileno(fp); int ierr; if (external_fd >= 0) { do { FD_ZERO(&fds); FD_SET(fd, &fds); FD_SET(external_fd, &fds); ierr = select(external_fd + 1, &fds, 0, 0, NULL); if (ierr < 0 && errno == EINTR) { #ifdef HAVE_LIBREADLINE if (_rl_caught_signal) _rl_signal_handler(_rl_caught_signal); #endif continue; } ... poll and read from external_fd ... } while (!FD_ISSET(fd, &fds)); } #ifdef HAVE_LIBREADLINE return rl_getc(fp); #else return getc(fp); #endif } ---- (2) the 1st ifdef block is simply replaced by ---- #ifdef HAVE_LIBREADLINE return rl_getc(fp); #endif ---- Both (1) and (2) suspend by Control-z. However, variant (2) does not accept input from external_fd (it is actually mouse driver) after continue from suspend, unless the first any input arrives from tty. I guess that this is inevitable with rl_getc(). How do you think?
...
You're right, as long as the application doesn't install any signal handlers. It's clear the rl_getc() workaround doesn't do everything you want in this case. Let's back up a bit. Why is Gnuplot attempting to use the readline signal handling framework when there isn't any readline code executing? Is the function fragment you showed assigned to rl_getc_function? If that's the case, I can see a reason to allow rl_getc replacements to use the readline signal handling infrastructure.
Exactly. The function shown above is a simplified version of getc_wrapper(), which gnuplot substitutes into rl_getc_function. For more details, please refer to src/readline.c, as well as x11_waitforinput() in term/x11.trm, which is called from getc_wrapper() via term->waitforinput(). I think that the fragment captures the essence of it although... Anyway, gnuplot assigns that function to rl_getc_function, in order to catch inputs both from tty and mouse (``external_fd'' in the above code). Gnuplot does not install any signal handlers by its own. rin
[Prev in Thread] | Current Thread | [Next in Thread] |