Preserve errno across signals.
This commit is contained in:
parent
a9874d4959
commit
286b86d62c
2
ndhc.c
2
ndhc.c
@ -149,6 +149,7 @@ void show_usage(void)
|
|||||||
|
|
||||||
static void signal_handler(int signo)
|
static void signal_handler(int signo)
|
||||||
{
|
{
|
||||||
|
int serrno = errno;
|
||||||
switch (signo) {
|
switch (signo) {
|
||||||
case SIGCHLD: {
|
case SIGCHLD: {
|
||||||
static const char errstr[] = "ndhc-master: Subprocess terminated unexpectedly. Exiting.\n";
|
static const char errstr[] = "ndhc-master: Subprocess terminated unexpectedly. Exiting.\n";
|
||||||
@ -161,6 +162,7 @@ static void signal_handler(int signo)
|
|||||||
case SIGUSR2: l_signal_release = 1; break;
|
case SIGUSR2: l_signal_release = 1; break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
errno = serrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
void signal_exit(int status)
|
void signal_exit(int status)
|
||||||
|
11
scriptd.c
11
scriptd.c
@ -123,14 +123,13 @@ static void do_scriptd_work(void)
|
|||||||
|
|
||||||
static void signal_handler(int signo)
|
static void signal_handler(int signo)
|
||||||
{
|
{
|
||||||
switch (signo) {
|
int serrno = errno;
|
||||||
case SIGCHLD:
|
if (signo == SIGCHLD) {
|
||||||
while (waitpid(-1, NULL, WNOHANG) > 0);
|
while (waitpid(-1, NULL, WNOHANG) > 0);
|
||||||
break;
|
} else if (signo == SIGINT || signo == SIGTERM) {
|
||||||
case SIGINT:
|
_exit(EXIT_FAILURE);
|
||||||
case SIGTERM: _exit(EXIT_FAILURE); break;
|
|
||||||
default: break;
|
|
||||||
}
|
}
|
||||||
|
errno = serrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setup_signals_scriptd(void)
|
static void setup_signals_scriptd(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user