aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-06-18 22:15:26 +0200
committerGravatar Christian Hesse <mail@eworm.de>2024-06-18 22:15:26 +0200
commit4ee8d1a8f00a8eec024c39a4abb50f8a81442e58 (patch)
treea1f1a85be25b0e5c1141b3602936f6b7d5994a40
parent521c3e28aaa254e05d2e05685bee648eadee582b (diff)
downloadnullshell-4ee8d1a8f00a8eec024c39a4abb50f8a81442e58.tar.gz
nullshell-4ee8d1a8f00a8eec024c39a4abb50f8a81442e58.tar.zst
use sigaction(2) instead of signal(2)HEADmain
As stated in the man pages, `sigaction` should be preferred to `signal`.
-rw-r--r--nullshell.c6
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 */