inetd: do not trash errno in signal handlers;
in CHLD handler, stop looping through services when pid is found function old new delta reread_config_file 1072 1092 +20 retry_network_setup 55 69 +14 reap_child 132 130 -2
This commit is contained in:
parent
41660c5b2d
commit
f54e62a3f2
@ -894,9 +894,10 @@ static void reread_config_file(int sig UNUSED_PARAM)
|
|||||||
sigset_t omask;
|
sigset_t omask;
|
||||||
unsigned n;
|
unsigned n;
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
|
int save_errno = errno;
|
||||||
|
|
||||||
if (!reopen_config_file())
|
if (!reopen_config_file())
|
||||||
return;
|
goto ret;
|
||||||
for (sep = serv_list; sep; sep = sep->se_next)
|
for (sep = serv_list; sep; sep = sep->se_next)
|
||||||
sep->se_checked = 0;
|
sep->se_checked = 0;
|
||||||
|
|
||||||
@ -1055,6 +1056,8 @@ static void reread_config_file(int sig UNUSED_PARAM)
|
|||||||
free(sep);
|
free(sep);
|
||||||
}
|
}
|
||||||
restore_sigmask(&omask);
|
restore_sigmask(&omask);
|
||||||
|
ret:
|
||||||
|
errno = save_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void reap_child(int sig UNUSED_PARAM)
|
static void reap_child(int sig UNUSED_PARAM)
|
||||||
@ -1068,8 +1071,9 @@ static void reap_child(int sig UNUSED_PARAM)
|
|||||||
pid = wait_any_nohang(&status);
|
pid = wait_any_nohang(&status);
|
||||||
if (pid <= 0)
|
if (pid <= 0)
|
||||||
break;
|
break;
|
||||||
for (sep = serv_list; sep; sep = sep->se_next)
|
for (sep = serv_list; sep; sep = sep->se_next) {
|
||||||
if (sep->se_wait == pid) {
|
if (sep->se_wait != pid)
|
||||||
|
continue;
|
||||||
/* One of our "wait" services */
|
/* One of our "wait" services */
|
||||||
if (WIFEXITED(status) && WEXITSTATUS(status))
|
if (WIFEXITED(status) && WEXITSTATUS(status))
|
||||||
bb_error_msg("%s: exit status 0x%x",
|
bb_error_msg("%s: exit status 0x%x",
|
||||||
@ -1079,6 +1083,7 @@ static void reap_child(int sig UNUSED_PARAM)
|
|||||||
sep->se_program, WTERMSIG(status));
|
sep->se_program, WTERMSIG(status));
|
||||||
sep->se_wait = 1;
|
sep->se_wait = 1;
|
||||||
add_fd_to_set(sep->se_fd);
|
add_fd_to_set(sep->se_fd);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
@ -1086,6 +1091,7 @@ static void reap_child(int sig UNUSED_PARAM)
|
|||||||
|
|
||||||
static void retry_network_setup(int sig UNUSED_PARAM)
|
static void retry_network_setup(int sig UNUSED_PARAM)
|
||||||
{
|
{
|
||||||
|
int save_errno = errno;
|
||||||
servtab_t *sep;
|
servtab_t *sep;
|
||||||
|
|
||||||
alarm_armed = 0;
|
alarm_armed = 0;
|
||||||
@ -1098,6 +1104,7 @@ static void retry_network_setup(int sig UNUSED_PARAM)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
errno = save_errno;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void clean_up_and_exit(int sig UNUSED_PARAM)
|
static void clean_up_and_exit(int sig UNUSED_PARAM)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user