diff options
author | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-05-14 20:32:36 +0200 |
---|---|---|
committer | Holger Hans Peter Freyther <zecke@selfish.org> | 2011-05-14 20:32:36 +0200 |
commit | 5083c2ab6ddd1748b1bb0391e55775f00ca224c9 (patch) | |
tree | feceed4a40489a0c9e14c6fb6a055eb267c54040 | |
parent | eb490d3882f56559f758944552173a94c0500179 (diff) |
ipaccess: Terminate the application on CTRL+C or CTRL+D
The terminal is switched into the raw mode and no SIGs
are generated.
-rw-r--r-- | util/telnet-client.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/util/telnet-client.c b/util/telnet-client.c index d2addf2..15f4aed 100644 --- a/util/telnet-client.c +++ b/util/telnet-client.c @@ -52,8 +52,16 @@ static void _input(char *buffer, int size) { for (i = 0; i != size; ++i) { /* if we got a CR or LF, replace with CRLF * NOTE that usually you'd get a CR in UNIX, but in raw - * mode we get LF instead (not sure why) + * mode we get LF instead (not sure why). + * For CTRL+C (SIGINT), CTRL+D (EOF) we will exit */ +#if NANO_BTS_CLI_CLIENT + if (buffer[i] == 3 || buffer[i] == 4) { + printf("%s terminating.\r\n", + buffer[i] == 3 ? "SIGINT" : "EOF"); + exit(0); + } +#endif if (buffer[i] == '\r' || buffer[i] == '\n') { if (do_echo) printf("\r\n"); |