From 29aedbd22b5e3529aff1f85ec1b3164118b83291 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Mon, 1 Jan 2018 13:11:16 +1000 Subject: [PATCH] Enable ^Z (SUSP) support Allows the current process to be backgrounded and then resumed. Signed-off-by: Steve Bennett --- linenoise.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/linenoise.c b/linenoise.c index f65d383..aee3447 100644 --- a/linenoise.c +++ b/linenoise.c @@ -129,6 +129,7 @@ #include #include #include +#include #include #include @@ -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) { -- 2.44.0