core/exec-invoke: sigwait() returns positive errno and never EINTR

Follow-up for 5b6319dcee (gosh this is
ancient), and effectively reverts 3dead8d925.

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.
This commit is contained in:
Mike Yuan
2023-12-10 09:44:44 +01:00
committed by Daan De Meyer
parent a753d30303
commit c8f7c9a11d
+4 -12
View File
@@ -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);