From 2ab4648096c23d274c8f74997e271ca5cdcc6cac Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Wed, 30 Oct 2024 01:55:25 +0100 Subject: Added SIGSTOP handling for suspending on ctrl-z --- README.md | 2 ++ chatty.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 5922b01..c6f0e0a 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ The idea is the following: - [ ] timeout on recv? - [ ] use threads to handle clients/ timeout when receiving because a client could theoretically stall the entire server. +- [ ] do not crash on errors from clients + - implement error message? ## common - [x] handle messages that are too large diff --git a/chatty.c b/chatty.c index e721a29..bd131a5 100644 --- a/chatty.c +++ b/chatty.c @@ -471,6 +471,13 @@ main(int argc, char** argv) ninput--; } break; + case TB_KEY_CTRL_Z: { + pid_t pid = getpid(); + tb_shutdown(); + kill(pid, SIGSTOP); + tb_init(); + } break; + case TB_KEY_CTRL_D: case TB_KEY_CTRL_C: quit = 1; -- cgit v1.2.3