From: Lennart Poettering Date: Sat, 10 Jul 2010 14:30:30 +0000 (+0200) Subject: daemon: make sure we never choke on SIGPIPE X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=51f97cbf68b80b56c52e351c539a37b7673b8920;p=catta daemon: make sure we never choke on SIGPIPE --- diff --git a/avahi-daemon/main.c b/avahi-daemon/main.c index de84f0f..b6962cf 100644 --- a/avahi-daemon/main.c +++ b/avahi-daemon/main.c @@ -1075,6 +1075,16 @@ static void signal_callback(AvahiWatch *watch, AVAHI_GCC_UNUSED int fd, AVAHI_GC /* Imported from ../avahi-client/nss-check.c */ int avahi_nss_support(void); +static void ignore_signal(int sig) { + struct sigaction sa; + + memset(&sa, 0, sizeof(sa)); + sa.sa_handler = SIG_IGN; + sa.sa_flags = SA_RESTART; + + sigaction(sig, &sa, NULL); +} + static int run_server(DaemonConfig *c) { int r = -1; int error; @@ -1091,6 +1101,8 @@ static int run_server(DaemonConfig *c) { assert(c); + ignore_signal(SIGPIPE); + if (!(nss_support = avahi_nss_support())) avahi_log_warn("WARNING: No NSS support for mDNS detected, consider installing nss-mdns!");