From 400d8bb45ee25ce226bb343a3dfaab84e6d3a8e1 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Sun, 24 Feb 2008 13:36:01 +0000 Subject: less,klogd,syslogd,nc,tcpudp: exit on signal by killing itself, not exit(1) *: minor shrink --- libbb/signals.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'libbb') diff --git a/libbb/signals.c b/libbb/signals.c index f7e4908e7..b46b595da 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 */ +} -- cgit v1.2.3