]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
block SIGPIPE in the daemon to prevent a SIGPIPE on write to a dead socket
authorAndrew Tridgell <tridge@samba.org>
Tue, 17 Apr 2007 05:33:20 +0000 (15:33 +1000)
committerAndrew Tridgell <tridge@samba.org>
Tue, 17 Apr 2007 05:33:20 +0000 (15:33 +1000)
(This used to be ctdb commit 02c09dc07c9bed57ca3692b14e41ac8cca0a29f4)

ctdb/common/ctdb_daemon.c

index 5a90003bc0ddfe8b5bee34f3ddab68c0a4e70aae..67653202af2c2786715b1c6659c52548a304c99d 100644 (file)
@@ -25,6 +25,7 @@
 #include "lib/util/dlinklist.h"
 #include "system/network.h"
 #include "system/filesys.h"
+#include "system/wait.h"
 #include "../include/ctdb.h"
 #include "../include/ctdb_private.h"
 
@@ -47,6 +48,18 @@ static void set_non_blocking(int fd)
         fcntl(fd, F_SETFL, v | O_NONBLOCK);
 }
 
+static void block_signal(int signum)
+{
+       struct sigaction act;
+
+       memset(&act, 0, sizeof(act));
+
+       act.sa_handler = SIG_IGN;
+       sigemptyset(&act.sa_mask);
+       sigaddset(&act.sa_mask, signum);
+       sigaction(signum, &act, NULL);
+}
+
 
 /*
   structure describing a connected client in the daemon
@@ -558,6 +571,8 @@ int ctdb_start(struct ctdb_context *ctdb)
                return 0;
        }
 
+       block_signal(SIGPIPE);
+
        /* ensure the socket is deleted on exit of the daemon */
        domain_socket_name = talloc_strdup(talloc_autofree_context(), ctdb->daemon.name);
        talloc_set_destructor(domain_socket_name, unlink_destructor);