diff options
author | Christian Hesse <mail@eworm.de> | 2016-10-06 22:20:25 +0200 |
---|---|---|
committer | Christian Hesse <mail@eworm.de> | 2016-10-06 22:20:25 +0200 |
commit | 908ebc33ef35df740aae9a36c9f9d4dc8a854237 (patch) | |
tree | b2bc8a8a4dd7503c783284a7b8817bb23b600f60 | |
parent | d00311eef068f4432a0e7e28f7b92890a785fe7c (diff) | |
download | paccache-908ebc33ef35df740aae9a36c9f9d4dc8a854237.tar.gz paccache-908ebc33ef35df740aae9a36c9f9d4dc8a854237.tar.zst |
fix race condition with SIGHUP
-rw-r--r-- | pacredir.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -549,6 +549,11 @@ int main(int argc, char ** argv) { ignore_interfaces->interface = NULL; ignore_interfaces->next = NULL; + /* Probing for static pacserve and pacdbserve hosts takes some time. + * Receiving a SIGHUP at this time could kill us. So register signal + * SIGHUP here before probing. */ + signal(SIGHUP, sighup_callback); + /* parse config file */ if ((ini = iniparser_load(CONFIGFILE)) == NULL) { write_log(stderr, "cannot parse file " CONFIGFILE ", continue anyway\n"); @@ -658,10 +663,10 @@ int main(int argc, char ** argv) { /* initialize curl */ curl_global_init(CURL_GLOBAL_ALL); - /* register signal callbacks */ + /* register SIG{TERM,KILL,INT} signal callbacks */ signal(SIGTERM, sig_callback); + signal(SIGKILL, sig_callback); signal(SIGINT, sig_callback); - signal(SIGHUP, sighup_callback); /* run the main loop */ avahi_simple_poll_loop(simple_poll); |