OSDN Git Service

android: No need for volatile sig_atomic_t when using signalfd
authorMarcel Holtmann <marcel@holtmann.org>
Thu, 31 Oct 2013 19:14:16 +0000 (12:14 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 31 Oct 2013 19:14:16 +0000 (12:14 -0700)
android/main.c

index 9ac18e5..8d93644 100644 (file)
@@ -72,8 +72,6 @@ static guint adapter_timeout = 0;
 static GIOChannel *hal_cmd_io = NULL;
 static GIOChannel *hal_notif_io = NULL;
 
-static volatile sig_atomic_t __terminated = 0;
-
 static bool services[HAL_SERVICE_ID_MAX + 1] = { false };
 
 static void service_register(void *buf, uint16_t len)
@@ -322,6 +320,7 @@ static gboolean cmd_connect_cb(GIOChannel *io, GIOCondition cond,
 static gboolean signal_handler(GIOChannel *channel, GIOCondition cond,
                                                        gpointer user_data)
 {
+       static bool __terminated = false;
        struct signalfd_siginfo si;
        ssize_t result;
        int fd;
@@ -338,12 +337,12 @@ static gboolean signal_handler(GIOChannel *channel, GIOCondition cond,
        switch (si.ssi_signo) {
        case SIGINT:
        case SIGTERM:
-               if (__terminated == 0) {
+               if (!__terminated) {
                        info("Terminating");
                        g_main_loop_quit(event_loop);
                }
 
-               __terminated = 1;
+               __terminated = true;
                break;
        }