aboutsummaryrefslogtreecommitdiffstats
path: root/pacredir.c
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2016-10-06 22:20:25 +0200
committerGravatar Christian Hesse <mail@eworm.de>2016-10-06 22:20:25 +0200
commit908ebc33ef35df740aae9a36c9f9d4dc8a854237 (patch)
treeb2bc8a8a4dd7503c783284a7b8817bb23b600f60 /pacredir.c
parentd00311eef068f4432a0e7e28f7b92890a785fe7c (diff)
downloadpacredir-908ebc33ef35df740aae9a36c9f9d4dc8a854237.tar.gz
pacredir-908ebc33ef35df740aae9a36c9f9d4dc8a854237.tar.zst
fix race condition with SIGHUP
Diffstat (limited to 'pacredir.c')
-rw-r--r--pacredir.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/pacredir.c b/pacredir.c
index 273dd39..1f8f658 100644
--- a/pacredir.c
+++ b/pacredir.c
@@ -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);