From c8f7c9a11dcc985fa1e2701b7b9aa2a129e194a5 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Sat, 9 Dec 2023 02:22:04 +0800 Subject: [PATCH] core/exec-invoke: sigwait() returns positive errno and never EINTR Follow-up for 5b6319dceedd81f3f1ce7eb70ea5defaef43bcec (gosh this is ancient), and effectively reverts 3dead8d925ea9db1fbd65b702b6b807e49ddeacf. sigwait() is documented to "suspend execution of the calling thread until one of the signals specified in the signal set becomes pending". And the only error it returns is EINVAL, when "set contains an invalid signal number". Therefore, there's no need to run it in a loop or to check for runtime error. --- src/core/exec-invoke.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/core/exec-invoke.c b/src/core/exec-invoke.c index b0f8e1178ec..c73b221d743 100644 --- a/src/core/exec-invoke.c +++ b/src/core/exec-invoke.c @@ -1204,7 +1204,7 @@ static int setup_pam( if (r < 0) goto fail; if (r == 0) { - int sig, ret = EXIT_PAM; + int ret = EXIT_PAM; /* The child's job is to reset the PAM session on termination */ barrier_set_role(&barrier, BARRIER_CHILD); @@ -1238,21 +1238,13 @@ static int setup_pam( /* Check if our parent process might already have died? */ if (getppid() == parent_pid) { sigset_t ss; + int sig; assert_se(sigemptyset(&ss) >= 0); assert_se(sigaddset(&ss, SIGTERM) >= 0); - for (;;) { - if (sigwait(&ss, &sig) < 0) { - if (errno == EINTR) - continue; - - goto child_finish; - } - - assert(sig == SIGTERM); - break; - } + assert_se(sigwait(&ss, &sig) == 0); + assert(sig == SIGTERM); } pam_code = pam_setcred(handle, PAM_DELETE_CRED | flags); -- 2.39.2