summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichel Stam <m.stam@fugro.nl>2014-10-13 16:14:36 +0200
committerJohn Crispin <blogic@openwrt.org>2014-10-12 13:24:11 +0200
commit3ff99010e61a0299257ffc91467a16d278a7e774 (patch)
tree6c3cc68e3faa034a25bee91e320dabb47c014b41
parent8b27adcf7516fa89ced66c840cfb085f2b6067af (diff)
downloadunitd-3ff99010e61a0299257ffc91467a16d278a7e774.tar
unitd-3ff99010e61a0299257ffc91467a16d278a7e774.zip
Fix ctrl+alt+del support
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>
-rw-r--r--procd.c3
-rw-r--r--signal.c2
-rw-r--r--state.c2
3 files changed, 4 insertions, 3 deletions
diff --git a/procd.c b/procd.c
index f5640c3..8dcd924 100644
--- 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;
}
diff --git a/signal.c b/signal.c
index 12eedc8..16824f7 100644
--- 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 7f0ec50..0896e1a 100644
--- 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();