From 301f58200202f5a7d17617e293ed2da5e350c9da Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 8 May 2019 06:46:36 -0400 Subject: [PATCH] Handle SIGINT when searching in editline --- src/rpc/cli.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/rpc/cli.cpp b/src/rpc/cli.cpp index ac518c3..c4e44ce 100644 --- a/src/rpc/cli.cpp +++ b/src/rpc/cli.cpp @@ -257,16 +257,24 @@ static int cli_check_secret(const char *source) return 0; } +static int cli_quitting = false; + /** * Get next character from stdin, or EOF if got a SIGINT signal */ static int interruptible_getc(void) { + if( cli_quitting ) + return EOF; + int r; char c; r = read(0, &c, 1); // read from stdin, will return -1 on SIGINT + if( r == -1 && errno == EINTR ) + cli_quitting = true; + return r == 1 ? c : EOF; }