Ignore Sigpipe in netd

Bug:6141847

Ignore sigpipe in netd. This will enable us remove the temporary
changes in DnsProxyListener that we added to temporarily resolve
issue 6138617.

Change-Id: I4bc13ac0fcf9dd0e7641c2d4459b1eab0ed50f2a
diff --git a/main.cpp b/main.cpp
index 2a1e7f0..14eb729 100644
--- a/main.cpp
+++ b/main.cpp
@@ -36,6 +36,7 @@
 
 static void coldboot(const char *path);
 static void sigchld_handler(int sig);
+static void blockSigpipe();
 
 int main() {
 
@@ -46,6 +47,7 @@
     ALOGI("Netd 1.0 starting");
 
 //    signal(SIGCHLD, sigchld_handler);
+    blockSigpipe();
 
     if (!(nm = NetlinkManager::Instance())) {
         ALOGE("Unable to create NetlinkManager");
@@ -136,3 +138,13 @@
     pid_t pid = wait(NULL);
     ALOGD("Child process %d exited", pid);
 }
+
+static void blockSigpipe()
+{
+    sigset_t mask;
+
+    sigemptyset(&mask);
+    sigaddset(&mask, SIGPIPE);
+    if (sigprocmask(SIG_BLOCK, &mask, NULL) != 0)
+        ALOGW("WARNING: SIGPIPE not blocked\n");
+}