From 4ee8d1a8f00a8eec024c39a4abb50f8a81442e58 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 18 Jun 2024 22:15:26 +0200 Subject: use sigaction(2) instead of signal(2) As stated in the man pages, `sigaction` should be preferred to `signal`. --- nullshell.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nullshell.c b/nullshell.c index 9218c18..6dfab1b 100644 --- a/nullshell.c +++ b/nullshell.c @@ -54,8 +54,10 @@ int main(int argc, char **argv) { ssh_tty = getenv("SSH_TTY"); /* register signal callbacks */ - signal(SIGTERM, sig_callback); - signal(SIGINT, sig_callback); + struct sigaction act = { 0 }; + act.sa_handler = sig_callback; + sigaction(SIGINT, &act, NULL); + sigaction(SIGTERM, &act, NULL); /* clear the screen and set cursor to the top left * see 'man 4 console_codes' for details */ -- cgit v1.2.3-70-g09d2