sf: Block SIGPIPE signal to avoid crash
Block SIGPIPE signal in surfaceflinger process during initialization.
This is required to avoid SIGPIPE crash when client closes the read
pipe fd in the other end.
Change-Id: I329d63ae9630c3dd76000d3b64d425a463c742e4
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index eb09ea1..4b7d3a0 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -415,6 +415,12 @@
status_t err;
Mutex::Autolock _l(mStateLock);
+ /* Set the mask bit of the sigset to block the SIGPIPE signal */
+ sigset_t sigMask;
+ sigemptyset (&sigMask);
+ sigaddset(&sigMask, SIGPIPE);
+ sigprocmask(SIG_BLOCK, &sigMask, NULL);
+
// initialize EGL for the default display
mEGLDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglInitialize(mEGLDisplay, NULL, NULL);