diff options
author | Christian Hesse <mail@eworm.de> | 2024-06-18 22:15:26 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2024-06-18 22:15:26 +0200 |
commit | 4ee8d1a8f00a8eec024c39a4abb50f8a81442e58 (patch) | |
tree | a1f1a85be25b0e5c1141b3602936f6b7d5994a40 | |
parent | 521c3e28aaa254e05d2e05685bee648eadee582b (diff) | |
download | nullshell-main.tar.gz nullshell-main.tar.zst |
As stated in the man pages, `sigaction` should be preferred to `signal`.
-rw-r--r-- | nullshell.c | 6 |
1 files 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 */ |