Fix ctrl+alt+del support
authorMichel Stam <m.stam@fugro.nl>
Mon, 13 Oct 2014 14:14:36 +0000 (16:14 +0200)
committerJohn Crispin <blogic@openwrt.org>
Sun, 12 Oct 2014 11:24:11 +0000 (13:24 +0200)
The previous patch did not catch SIGINT, which is used by the
kernel to indicate to the init process that the system should
reboot.

Signed-off-by: Michel Stam <m.stam@fugro.nl>
procd.c
signal.c
state.c

diff --git a/procd.c b/procd.c
index f5640c3b968a607f6c2321c27da787562defcc82..8dcd924ebabbc1cba4996401b43e988743ac03f8 100644 (file)
--- a/procd.c
+++ b/procd.c
@@ -72,8 +72,5 @@ int main(int argc, char **argv)
        uloop_run();
        uloop_done();
 
-       if (getpid() == 1)
-               procd_shutdown(RB_AUTOBOOT);
-
        return 0;
 }
index 12eedc8ca976bc8a28940097d4af90cd2bda133a..16824f7251b5c01344c4f1dd939ed0daef9ac022 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -36,6 +36,7 @@ static void signal_shutdown(int signal, siginfo_t *siginfo, void *data)
        char *msg = NULL;
 
        switch(signal) {
+       case SIGINT:
        case SIGTERM:
                event = RB_AUTOBOOT;
                msg = "reboot";
@@ -84,6 +85,7 @@ void procd_signal(void)
        if (getpid() != 1)
                return;
        sigaction(SIGTERM, &sa_shutdown, NULL);
+       sigaction(SIGINT, &sa_shutdown, NULL);
        sigaction(SIGUSR1, &sa_shutdown, NULL);
        sigaction(SIGUSR2, &sa_shutdown, NULL);
        sigaction(SIGSEGV, &sa_crash, NULL);
diff --git a/state.c b/state.c
index 7f0ec508566188d8e6a1e7afa34408c04634cde0..0896e1ae34f6430ad7abdee5ba5d46f3dfc238a3 100644 (file)
--- a/state.c
+++ b/state.c
@@ -131,6 +131,8 @@ static void state_enter(void)
                break;
 
        case STATE_HALT:
+               // To prevent killed processes from interrupting the sleep
+               signal(SIGCHLD, SIG_IGN);
                LOG("- SIGTERM processes -\n");
                kill(-1, SIGTERM);
                sync();