From: Steve Bennett Date: Mon, 1 Jan 2018 03:11:16 +0000 (+1000) Subject: Enable ^Z (SUSP) support X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=29aedbd22b5e3529aff1f85ec1b3164118b83291;p=linenoise.git Enable ^Z (SUSP) support Allows the current process to be backgrounded and then resumed. Signed-off-by: Steve Bennett --- 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) {