]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
core/exec-invoke: sigwait() returns positive errno and never EINTR
authorMike Yuan <me@yhndnzj.com>
Fri, 8 Dec 2023 18:22:04 +0000 (02:22 +0800)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 10 Dec 2023 08:44:44 +0000 (09:44 +0100)
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

index b0f8e1178ecd184a05333a4b51b90ee9f567f024..c73b221d743e1cc23d22970d13aba43d38836c0a 100644 (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);