From 860e6f3584950957a3e30952c105413982afa654 Mon Sep 17 00:00:00 2001 From: Joerg Siebenmorgen Date: Sat, 8 Aug 2026 13:45:35 +0200 Subject: [PATCH 1/2] CONSOLE: Fix continue after CTRL+Z --- src/platform/console/device.cpp | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/platform/console/device.cpp b/src/platform/console/device.cpp index 4ca56d92..159ff66c 100644 --- a/src/platform/console/device.cpp +++ b/src/platform/console/device.cpp @@ -132,13 +132,24 @@ void console_init() { #if USE_TERM_IO struct winsize consoleSize; -struct termios original_termios; +struct termios raw_termios, original_termios; /** - * @brief Handler for Ctrl+C + * @brief Handler for: + * - Ctrl+C + * - Switch back from suspended by Ctrl+Z */ void handle_signal(int sig) { - brun_break(); + switch (sig) { + case SIGCONT: + tcsetattr(STDIN_FILENO, TCSANOW, &raw_termios); + break; + case SIGINT: + case SIGTERM: + case SIGHUP: + brun_break(); + break; + } } /** @@ -149,7 +160,7 @@ void terminal_init(void) { tcgetattr(STDIN_FILENO, &original_termios); // 2. Copy them for restoration later - struct termios raw = original_termios; + raw_termios = original_termios; // 3. Modify settings: // Disable canonical mode (ICANON) @@ -161,16 +172,16 @@ void terminal_init(void) { // Disable parity checking (INPCK) // Disable stripping of 8th bit of each input (ISTRIP) // Set character size to 8 bit (CS8) - raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); - raw.c_cflag |= (CS8); - raw.c_lflag &= ~(ECHO | ICANON | IEXTEN); + raw_termios.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON); + raw_termios.c_cflag |= (CS8); + raw_termios.c_lflag &= ~(ECHO | ICANON | IEXTEN); // 4. Set timeout and minimum number of bytes for read() - raw.c_cc[VMIN] = 0; - raw.c_cc[VTIME] = 0; + raw_termios.c_cc[VMIN] = 0; + raw_termios.c_cc[VTIME] = 0; // 5. Apply the new settings - tcsetattr(STDIN_FILENO, TCSANOW, &raw); + tcsetattr(STDIN_FILENO, TCSANOW, &raw_termios); // 6. Register signal handlers struct sigaction sa = {0}; @@ -180,6 +191,7 @@ void terminal_init(void) { sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); sigaction(SIGHUP, &sa, NULL); + sigaction(SIGCONT, &sa, NULL); } void terminal_getSize(int *x, int *y) { From fd27f73b48c4d9167795783c4bfda28b81dc0972 Mon Sep 17 00:00:00 2001 From: Joerg Siebenmorgen Date: Sat, 8 Aug 2026 19:56:24 +0200 Subject: [PATCH 2/2] CONSOLE: Fix continue after CTRL+Z --- src/platform/console/device.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/console/device.cpp b/src/platform/console/device.cpp index 159ff66c..3e59ecef 100644 --- a/src/platform/console/device.cpp +++ b/src/platform/console/device.cpp @@ -187,7 +187,7 @@ void terminal_init(void) { struct sigaction sa = {0}; sa.sa_handler = handle_signal; sigemptyset(&sa.sa_mask); - sa.sa_flags = SA_RESETHAND; + sa.sa_flags = 0; sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); sigaction(SIGHUP, &sa, NULL);