summaryrefslogtreecommitdiff
path: root/libbb/signals.c
diff options
context:
space:
mode:
authorDenis Vlasenko2008-02-24 13:36:01 +0000
committerDenis Vlasenko2008-02-24 13:36:01 +0000
commit400d8bb45ee25ce226bb343a3dfaab84e6d3a8e1 (patch)
treeaa3cdc9a663f1ac2467803fc215899d86ed1db74 /libbb/signals.c
parentd553faf5a53cf9d72e16fc789451a92a797f1b70 (diff)
downloadbusybox-400d8bb45ee25ce226bb343a3dfaab84e6d3a8e1.zip
busybox-400d8bb45ee25ce226bb343a3dfaab84e6d3a8e1.tar.gz
less,klogd,syslogd,nc,tcpudp: exit on signal by killing itself, not exit(1)
*: minor shrink
Diffstat (limited to 'libbb/signals.c')
-rw-r--r--libbb/signals.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/libbb/signals.c b/libbb/signals.c
index f7e4908..b46b595 100644
--- a/libbb/signals.c
+++ b/libbb/signals.c
@@ -78,3 +78,17 @@ void sig_pause(void)
sigemptyset(&ss);
sigsuspend(&ss);
}
+
+/* Assuming the sig is fatal */
+void kill_myself_with_sig(int sig)
+{
+ sigset_t set;
+
+ signal(sig, SIG_DFL);
+
+ sigemptyset(&set);
+ sigaddset(&set, sig);
+ sigprocmask(SIG_UNBLOCK, &set, NULL);
+ raise(sig);
+ _exit(1); /* Should not reach it */
+}