less,klogd,syslogd,nc,tcpudp: exit on signal by killing itself, not exit(1)

*: minor shrink
This commit is contained in:
Denis Vlasenko
2008-02-24 13:36:01 +00:00
parent d553faf5a5
commit 400d8bb45e
14 changed files with 68 additions and 57 deletions

View File

@ -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 */
}