mirror of
https://github.com/systemd/systemd.git
synced 2026-07-26 03:06:21 +00:00
process-util: introduce SIGINFO_CODE_IS_DEAD helper
This commit is contained in:
@@ -61,6 +61,10 @@ int get_process_umask(pid_t pid, mode_t *ret);
|
||||
|
||||
int container_get_leader(const char *machine, pid_t *pid);
|
||||
|
||||
static inline bool SIGINFO_CODE_IS_DEAD(int code) {
|
||||
return IN_SET(code, CLD_EXITED, CLD_KILLED, CLD_DUMPED);
|
||||
}
|
||||
|
||||
int wait_for_terminate(pid_t pid, siginfo_t *status);
|
||||
|
||||
typedef enum WaitFlags {
|
||||
|
||||
@@ -2990,7 +2990,7 @@ static int manager_dispatch_sigchld(sd_event_source *source, void *userdata) {
|
||||
if (si.si_pid <= 0)
|
||||
goto turn_off;
|
||||
|
||||
if (IN_SET(si.si_code, CLD_EXITED, CLD_KILLED, CLD_DUMPED)) {
|
||||
if (SIGINFO_CODE_IS_DEAD(si.si_code)) {
|
||||
_cleanup_free_ char *name = NULL;
|
||||
(void) pid_get_comm(si.si_pid, &name);
|
||||
|
||||
|
||||
@@ -3760,7 +3760,7 @@ static int process_child(sd_event *e, int64_t threshold, int64_t *ret_min_priori
|
||||
return negative_errno();
|
||||
|
||||
if (s->child.siginfo.si_pid != 0) {
|
||||
bool zombie = IN_SET(s->child.siginfo.si_code, CLD_EXITED, CLD_KILLED, CLD_DUMPED);
|
||||
bool zombie = SIGINFO_CODE_IS_DEAD(s->child.siginfo.si_code);
|
||||
|
||||
if (zombie)
|
||||
s->child.exited = true;
|
||||
@@ -3809,7 +3809,7 @@ static int process_pidfd(sd_event *e, sd_event_source *s, uint32_t revents) {
|
||||
if (s->child.siginfo.si_pid == 0)
|
||||
return 0;
|
||||
|
||||
if (IN_SET(s->child.siginfo.si_code, CLD_EXITED, CLD_KILLED, CLD_DUMPED))
|
||||
if (SIGINFO_CODE_IS_DEAD(s->child.siginfo.si_code))
|
||||
s->child.exited = true;
|
||||
|
||||
return source_set_pending(s, true);
|
||||
@@ -4222,9 +4222,7 @@ static int source_dispatch(sd_event_source *s) {
|
||||
break;
|
||||
|
||||
case SOURCE_CHILD: {
|
||||
bool zombie;
|
||||
|
||||
zombie = IN_SET(s->child.siginfo.si_code, CLD_EXITED, CLD_KILLED, CLD_DUMPED);
|
||||
bool zombie = SIGINFO_CODE_IS_DEAD(s->child.siginfo.si_code);
|
||||
|
||||
r = s->child.callback(s, &s->child.siginfo, s->userdata);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user