OSDN Git Service

sens: fix server crash after stopping the poll client
[android-x86/hardware-intel-libsensors.git] / sens.c
diff --git a/sens.c b/sens.c
index efb5811..5be4cc0 100644 (file)
--- a/sens.c
+++ b/sens.c
@@ -9,6 +9,7 @@
 #include <dlfcn.h>
 #include <pthread.h>
 #include <errno.h>
+#include <signal.h>
 
 #include <hardware/sensors.h>
 #include <utils/Log.h>
@@ -176,8 +177,16 @@ static void run_sensors_poll_v0(void)
        }
 }
 
+static void sig_pipe(int sig)
+{
+       client = NULL;
+}
+
 static void *run_sensors_thread(void *arg __attribute((unused)))
 {
+
+       signal(SIGPIPE, sig_pipe);
+
        switch (dev->version) {
        case SENSORS_DEVICE_API_VERSION_0_1:
        default:
@@ -408,7 +417,6 @@ static int start_server(void)
                        fclose(f);
                }
 
-
                close(conn);
        }
 }