From e302b6b6356ade5b6c6d85bcab1a8055875294d6 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sat, 5 Oct 2024 19:05:04 +0300 Subject: [PATCH] Shell: Use sigaction instead of signal This allows ctrl-c to work on linux :D --- userspace/programs/Shell/main.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/userspace/programs/Shell/main.cpp b/userspace/programs/Shell/main.cpp index e95bda9c17..ecdf4a14c7 100644 --- a/userspace/programs/Shell/main.cpp +++ b/userspace/programs/Shell/main.cpp @@ -780,10 +780,14 @@ int main(int argc, char** argv) { realpath(argv[0], s_shell_path); - if (signal(SIGINT, [](int) {}) == SIG_ERR) - perror("signal"); - if (signal(SIGTTOU, SIG_IGN) == SIG_ERR) - perror("signal"); + struct sigaction sa; + sa.sa_flags = 0; + + sa.sa_handler = [](int) {}; + sigaction(SIGINT, &sa, nullptr); + + sa.sa_handler = SIG_IGN; + sigaction(SIGTTOU, &sa, nullptr); tcgetattr(0, &old_termios);