Hi,

Gnuplot on macOS does not suspend by Control-z in its command line.
Please find the details below and attached patch.

Best regards,
Rin Okuyama
----
* VERSION

7.0 (the latest git source as of 2017-11-21).

* ENVIRONMENT

macOS 10.13.1 (also observed on 10.8.5).

* COMPILATION FLAGS etc.

Default settings generated by configure script.

* DESCRIPTION

Gnuplot 5.2.2 (and maybe all other versions) does not suspend only by
Control-z in its command line. If you type any key after Control-z, it
receives SIGTSTP and suspends.

* RECIPE FOR REPRODUCE

Try to suspend gnuplot on macOS by Control-z key.

* FIX

At the moment, readline does not disable VSUSP, and expect SIGTSTP to
be appropriately sent by the tty driver. However, unfortunately, it
does not work on macOS.

By applying this patch, readline explicitly disables VSUSP, and handles
Control-z by its own.

Applications like bash should not suspend by Control-z. However, this
patch does not take care of such a case.
diff -Naru readline.orig/emacs_keymap.c readline/emacs_keymap.c
--- readline.orig/emacs_keymap.c        2017-11-21 20:44:52.000000000 +0900
+++ readline/emacs_keymap.c     2017-11-21 20:41:35.000000000 +0900
@@ -22,6 +22,7 @@
 #if !defined (BUFSIZ)
 #include <stdio.h>
 #endif /* !BUFSIZ */
+#include <signal.h>
 
 #include "readline.h"
 
@@ -58,7 +59,11 @@
   { ISFUNC, rl_unix_word_rubout },             /* Control-w */
   { ISKMAP, (rl_command_func_t *)emacs_ctlx_keymap },  /* Control-x */
   { ISFUNC, rl_yank },                         /* Control-y */
+#ifdef SIGTSTP
+  { ISFUNC, rl_suspend },                      /* Control-z */
+#else
   { ISFUNC, (rl_command_func_t *)0x0 },                /* Control-z */
+#endif
   { ISKMAP, (rl_command_func_t *)emacs_meta_keymap }, /* Control-[ */
   { ISFUNC, (rl_command_func_t *)0x0 },                /* Control-\ */
   { ISFUNC, rl_char_search },                  /* Control-] */
diff -Naru readline.orig/keymaps.c readline/keymaps.c
--- readline.orig/keymaps.c     2017-11-21 20:44:52.000000000 +0900
+++ readline/keymaps.c  2017-11-21 20:48:55.000000000 +0900
@@ -32,6 +32,7 @@
 #endif /* HAVE_STDLIB_H */
 
 #include <stdio.h>     /* for FILE * definition for readline.h */
+#include <signal.h>
 
 #include "readline.h"
 #include "rlconf.h"
@@ -113,6 +114,9 @@
   newmap[TAB].function = rl_insert;
   newmap[RUBOUT].function = rl_rubout; /* RUBOUT == 127 */
   newmap[CTRL('H')].function = rl_rubout;
+#ifdef SIGTSTP
+  newmap[CTRL('Z')].function = rl_suspend;
+#endif
 
 #if KEYMAP_SIZE > 128
   /* Printing characters in ISO Latin-1 and some 8-bit character sets. */
diff -Naru readline.orig/misc.c readline/misc.c
--- readline.orig/misc.c        2017-11-21 20:44:52.000000000 +0900
+++ readline/misc.c     2017-11-21 21:31:47.000000000 +0900
@@ -40,6 +40,7 @@
 #endif
 
 #include <stdio.h>
+#include <signal.h>
 
 /* System-specific feature definitions and include files. */
 #include "rldefs.h"
@@ -690,3 +691,14 @@
 
   return 0;
 }
+
+/* Suspend. */
+#ifdef SIGTSTP
+int
+rl_suspend (count, key)
+     int count, key;
+{
+  kill(0, SIGTSTP);
+  return 0;
+}
+#endif
diff -Naru readline.orig/readline.h readline/readline.h
--- readline.orig/readline.h    2017-11-21 20:44:52.000000000 +0900
+++ readline/readline.h 2017-11-21 20:59:40.000000000 +0900
@@ -141,6 +141,9 @@
 /* Bindable commands to change the insert mode (insert or overwrite) */
 extern int rl_overwrite_mode PARAMS((int, int));
 
+/* Bindable commands to suspend. */
+extern int rl_suspend PARAMS((int, int));
+
 /* Bindable commands for managing key bindings. */
 extern int rl_re_read_init_file PARAMS((int, int));
 extern int rl_dump_functions PARAMS((int, int));
diff -Naru readline.orig/rltty.c readline/rltty.c
--- readline.orig/rltty.c       2017-11-21 20:44:52.000000000 +0900
+++ readline/rltty.c    2017-11-21 21:02:49.000000000 +0900
@@ -574,6 +574,10 @@
   tiop->c_cc[VLNEXT] = _POSIX_VDISABLE;
 #endif
 
+#if defined (VSUSP)
+  tiop->c_cc[VSUSP] = _POSIX_VDISABLE;
+#endif
+
 #if defined (VDSUSP)
   tiop->c_cc[VDSUSP] = _POSIX_VDISABLE;
 #endif
diff -Naru readline.orig/stamp-h readline/stamp-h
--- readline.orig/stamp-h       1970-01-01 09:00:00.000000000 +0900
+++ readline/stamp-h    2017-11-21 20:11:13.000000000 +0900
@@ -0,0 +1 @@
+
diff -Naru readline.orig/vi_keymap.c readline/vi_keymap.c
--- readline.orig/vi_keymap.c   2017-11-21 20:44:52.000000000 +0900
+++ readline/vi_keymap.c        2017-11-21 20:42:25.000000000 +0900
@@ -58,7 +58,11 @@
   { ISFUNC, rl_vi_unix_word_rubout },          /* Control-w */
   { ISFUNC, (rl_command_func_t *)0x0 },                /* Control-x */
   { ISFUNC, rl_yank },                         /* Control-y */
+#ifndef SIGTSTP
+  { ISFUNC, rl_suspend },                      /* Control-z */
+#else
   { ISFUNC, (rl_command_func_t *)0x0 },                /* Control-z */
+#endif
 
   { ISFUNC, (rl_command_func_t *)0x0 },                /* Control-[ */ /* 
vi_escape_keymap */
   { ISFUNC, (rl_command_func_t *)0x0 },                /* Control-\ */
_______________________________________________
Bug-readline mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/bug-readline

Reply via email to