diff options
author | Christian Hesse <mail@eworm.de> | 2024-06-18 22:21:59 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2024-06-18 22:21:59 +0200 |
commit | 52ebbe544830fb9634f8b5b7fd57ca03e40aa62e (patch) | |
tree | fef332fa2ff7070a97dbece44fda2db057224f56 | |
parent | 7a858140c0aa43a972b2be0ee920c9bfe4ef94a8 (diff) | |
download | pacredir-52ebbe544830fb9634f8b5b7fd57ca03e40aa62e.tar.gz pacredir-52ebbe544830fb9634f8b5b7fd57ca03e40aa62e.tar.zst |
As stated in the man pages, `sigaction` should be preferred to `signal`.
-rw-r--r-- | pacredir.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -675,7 +675,9 @@ int main(int argc, char ** argv) { /* Probing for static pacserve hosts takes some time. * Receiving a SIGHUP at this time could kill us. So register signal * SIGHUP here before probing. */ - signal(SIGHUP, sighup_callback); + struct sigaction act_hup = { 0 }; + act_hup.sa_handler = sighup_callback; + sigaction(SIGHUP, &act_hup, NULL); /* parse config file */ if ((ini = iniparser_load(CONFIGFILE)) == NULL) { @@ -787,9 +789,11 @@ int main(int argc, char ** argv) { curl_global_init(CURL_GLOBAL_ALL); /* register SIG{TERM,KILL,INT} signal callbacks */ - signal(SIGTERM, sig_callback); - signal(SIGKILL, sig_callback); - signal(SIGINT, sig_callback); + struct sigaction act = { 0 }; + act.sa_handler = sig_callback; + sigaction(SIGTERM, &act, NULL); + sigaction(SIGKILL, &act, NULL); + sigaction(SIGINT, &act, NULL); /* report ready to systemd */ sd_notify(0, "READY=1\nSTATUS=Waiting for requests to redirect..."); |