]> git.lizzy.rs Git - linenoise.git/commitdiff
Enable ^Z (SUSP) support
authorSteve Bennett <steveb@workware.net.au>
Mon, 1 Jan 2018 03:11:16 +0000 (13:11 +1000)
committerSteve Bennett <steveb@workware.net.au>
Mon, 1 Jan 2018 03:11:16 +0000 (13:11 +1000)
Allows the current process to be backgrounded and then resumed.

Signed-off-by: Steve Bennett <steveb@workware.net.au>
linenoise.c

index f65d3834170fd0e12ca8e4e9db9a144127ddfcd5..aee34470d9316d317bd4afd15ca4e84c57246365 100644 (file)
 #include <stdio.h>
 #include <errno.h>
 #include <string.h>
+#include <signal.h>
 #include <stdlib.h>
 #include <sys/types.h>
 
@@ -1230,6 +1231,16 @@ process_char:
         case ctrl('C'):     /* ctrl-c */
             errno = EAGAIN;
             return -1;
+        case ctrl('Z'):     /* ctrl-z */
+#ifdef SIGTSTP
+            /* send ourselves SIGSUSP */
+            disableRawMode(current);
+            raise(SIGTSTP);
+            /* and resume */
+            enableRawMode(current);
+            refreshLine(current->prompt, current);
+#endif
+            continue;
         case 127:   /* backspace */
         case ctrl('H'):
             if (remove_char(current, current->pos - 1) == 1) {