SIGINT is captured by uloop by default. This does not work for
procd, where SIGINT is used by the kernel to indicate that the
system must be rebooted.

Signed-off-by: Michel Stam <m.s...@fugro.nl>
---
 uloop.c | 24 +++++++++++++++++-------
 uloop.h |  1 +
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/uloop.c b/uloop.c
index c3d206a..5180a80 100644
--- a/uloop.c
+++ b/uloop.c
@@ -57,6 +57,7 @@ static struct list_head timeouts = LIST_HEAD_INIT(timeouts);
 static struct list_head processes = LIST_HEAD_INIT(processes);
 
 static int poll_fd = -1;
+static bool uloop_catch_sigint = true;
 bool uloop_cancelled = false;
 bool uloop_handle_sigchld = true;
 static bool do_sigchld = false;
@@ -549,6 +550,11 @@ static void uloop_handle_processes(void)
 
 }
 
+void uloop_release_sigint(void)
+{
+       uloop_catch_sigint = false;
+}
+
 static void uloop_handle_sigint(int signo)
 {
        uloop_cancelled = true;
@@ -562,18 +568,22 @@ static void uloop_sigchld(int signo)
 static void uloop_setup_signals(bool add)
 {
        static struct sigaction old_sigint, old_sigchld;
+       static bool sigint_caught = false;
        struct sigaction s;
 
        memset(&s, 0, sizeof(struct sigaction));
 
-       if (add) {
-               s.sa_handler = uloop_handle_sigint;
-               s.sa_flags = 0;
-       } else {
-               s = old_sigint;
-       }
+       if (uloop_catch_sigint || sigint_caught) {
+               sigint_caught = true;
+               if (add) {
+                       s.sa_handler = uloop_handle_sigint;
+                       s.sa_flags = 0;
+               } else {
+                       s = old_sigint;
+               }
 
-       sigaction(SIGINT, &s, &old_sigint);
+               sigaction(SIGINT, &s, &old_sigint);
+       }
 
        if (!uloop_handle_sigchld)
                return;
diff --git a/uloop.h b/uloop.h
index 7564514..b38d213 100644
--- a/uloop.h
+++ b/uloop.h
@@ -105,5 +105,6 @@ static inline void uloop_end(void)
 int uloop_init(void);
 void uloop_run(void);
 void uloop_done(void);
+void uloop_release_sigint(void);
 
 #endif
-- 
1.7.12.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to