sd-event: Clean up SIGCHLD conditions for sd_event_add_child()
First, don't require blocking SIGCHLD for WEXITED. We watch for WEXITED via pidfd instead of signalfd, so no need to insist on blocking SIGCHLD anymore if we're only watching for WEXITED. Second, do a proper check to see if the kernel autoreaping logic is enabled. That has nothing to do with SIGCHLD being blocked for the current thread or not. Instead, the kernel autoreaping logic is enabled either if the disposition is set to SIG_IGN or if the SA_NOCLDWAIT flag is enabled.
This commit is contained in:
@@ -238,6 +238,15 @@ int signal_is_blocked(int sig) {
|
||||
return RET_NERRNO(sigismember(&ss, sig));
|
||||
}
|
||||
|
||||
int autoreaping_enabled(void) {
|
||||
struct sigaction sa;
|
||||
|
||||
if (sigaction(SIGCHLD, /* __act= */ NULL, &sa) < 0)
|
||||
return -errno;
|
||||
|
||||
return sa.sa_handler == SIG_IGN || FLAGS_SET(sa.sa_flags, SA_NOCLDWAIT);
|
||||
}
|
||||
|
||||
int pop_pending_signal_internal(int sig, ...) {
|
||||
sigset_t ss;
|
||||
va_list ap;
|
||||
|
||||
@@ -66,6 +66,8 @@ static inline const char* signal_to_string_with_check(int n) {
|
||||
|
||||
int signal_is_blocked(int sig);
|
||||
|
||||
int autoreaping_enabled(void);
|
||||
|
||||
int pop_pending_signal_internal(int sig, ...);
|
||||
#define pop_pending_signal(...) pop_pending_signal_internal(__VA_ARGS__, -1)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user