From 0857a0846f9d9025bf5900f548ac1369d629eb72 Mon Sep 17 00:00:00 2001 From: Claudio Matsuoka Date: Fri, 18 Apr 2008 15:48:15 -0300 Subject: [PATCH] Ignore signal instead of setting to an empty handler As suggested by Metalshark Signed-off-by: Claudio Matsuoka --- Changelog | 1 + finit-alt.c | 27 +++++++++------------------ finit-mod.c | 29 ++++++++++------------------- 3 files changed, 20 insertions(+), 37 deletions(-) diff --git a/Changelog b/Changelog index 7284c0e1..bc2d48d7 100644 --- a/Changelog +++ b/Changelog @@ -3,6 +3,7 @@ O.4 () - default username for finit-alt configurable in Makefile - create loopback device node in finit-alt (for squashfs) - add option to use built-in run-parts instead of /bin/run-parts + - ignore signal instead of setting to an empty handler (Metalshark) 0.3 (20080223) - Change poweroff method to reboot(RB_POWER_OFF) (Metalshark) diff --git a/finit-alt.c b/finit-alt.c index fb3ff022..1c770782 100644 --- a/finit-alt.c +++ b/finit-alt.c @@ -121,15 +121,15 @@ int main() for (i = 1; i < NSIG; i++) SETSIG(sa, i, SIG_IGN, SA_RESTART); - SETSIG(sa, SIGINT, shutdown, 0); - SETSIG(sa, SIGPWR, signal_handler, 0); - SETSIG(sa, SIGUSR1, shutdown, 0); - SETSIG(sa, SIGUSR2, shutdown, 0); - SETSIG(sa, SIGTERM, signal_handler, 0); - SETSIG(sa, SIGALRM, signal_handler, 0); - SETSIG(sa, SIGHUP, signal_handler, 0); - SETSIG(sa, SIGCONT, signal_handler, SA_RESTART); - SETSIG(sa, SIGCHLD, chld_handler, SA_RESTART); + SETSIG(sa, SIGINT, shutdown, 0); + SETSIG(sa, SIGPWR, SIG_IGN, 0); + SETSIG(sa, SIGUSR1, shutdown, 0); + SETSIG(sa, SIGUSR2, shutdown, 0); + SETSIG(sa, SIGTERM, SIG_IGN, 0); + SETSIG(sa, SIGALRM, SIG_IGN, 0); + SETSIG(sa, SIGHUP, SIG_IGN, 0); + SETSIG(sa, SIGCONT, SIG_IGN, SA_RESTART); + SETSIG(sa, SIGCHLD, chld_handler, SA_RESTART); /* Block sigchild while forking */ sigemptyset(&nmask); @@ -379,12 +379,3 @@ void chld_handler(int sig) } } - -/* - * We got a signal (PWR TERM ALRM HUP CONT) - */ -void signal_handler(int sig) -{ - /* do nothing */ -} - diff --git a/finit-mod.c b/finit-mod.c index 30f11236..59594289 100644 --- a/finit-mod.c +++ b/finit-mod.c @@ -41,6 +41,7 @@ Changelog from the original Eeepc fastinit: - Change poweroff method from writing 5 to /sys/power/state to reboot(RB_POWER_OFF) (by Metalshark) - Mount /var/run and /var/lock as tmpfs +- Use SIG_IGN instead of empty signal handler (by Metalshark) */ @@ -83,7 +84,6 @@ Changelog from the original Eeepc fastinit: void shutdown(int); -void signal_handler(int); void chld_handler(int); @@ -112,15 +112,15 @@ int main() for (i = 1; i < NSIG; i++) SETSIG(sa, i, SIG_IGN, SA_RESTART); - SETSIG(sa, SIGINT, shutdown, 0); - SETSIG(sa, SIGPWR, signal_handler, 0); - SETSIG(sa, SIGUSR1, shutdown, 0); - SETSIG(sa, SIGUSR2, shutdown, 0); - SETSIG(sa, SIGTERM, signal_handler, 0); - SETSIG(sa, SIGALRM, signal_handler, 0); - SETSIG(sa, SIGHUP, signal_handler, 0); - SETSIG(sa, SIGCONT, signal_handler, SA_RESTART); - SETSIG(sa, SIGCHLD, chld_handler, SA_RESTART); + SETSIG(sa, SIGINT, shutdown, 0); + SETSIG(sa, SIGPWR, SIG_IGN, 0); + SETSIG(sa, SIGUSR1, shutdown, 0); + SETSIG(sa, SIGUSR2, shutdown, 0); + SETSIG(sa, SIGTERM, SIG_IGN, 0); + SETSIG(sa, SIGALRM, SIG_IGN, 0); + SETSIG(sa, SIGHUP, SIG_IGN, 0); + SETSIG(sa, SIGCONT, SIG_IGN, SA_RESTART); + SETSIG(sa, SIGCHLD, chld_handler, SA_RESTART); /* Block sigchild while forking */ sigemptyset(&nmask); @@ -318,12 +318,3 @@ void chld_handler(int sig) } } - -/* - * We got a signal (PWR TERM ALRM HUP CONT) - */ -void signal_handler(int sig) -{ - /* do nothing */ -} -