aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2024-06-18 22:21:59 +0200
committerGravatar Christian Hesse <mail@eworm.de>2024-06-18 22:21:59 +0200
commit52ebbe544830fb9634f8b5b7fd57ca03e40aa62e (patch)
treefef332fa2ff7070a97dbece44fda2db057224f56
parent7a858140c0aa43a972b2be0ee920c9bfe4ef94a8 (diff)
downloadpacredir-main.tar.gz
pacredir-main.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--pacredir.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/pacredir.c b/pacredir.c
index cf92b60..4bfb16c 100644
--- a/pacredir.c
+++ b/pacredir.c
@@ -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...");