]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/async: don't use WEXITED for waitpid() 28348/head
authorMike Yuan <me@yhndnzj.com>
Mon, 10 Jul 2023 17:46:29 +0000 (01:46 +0800)
committerMike Yuan <me@yhndnzj.com>
Tue, 11 Jul 2023 04:08:09 +0000 (12:08 +0800)
Follow-up for c26d7837bb08508c8d906d849dff8f1bc465063e

waitpid() doesn't support WEXITED and returns -1 (EINVAL),
which results in the intermediate close process not getting
reaped.

Fixes https://github.com/systemd/systemd/issues/26744#issuecomment-1628240782

src/shared/async.c

index 1cf1936d4b1740bf240339496cb088c69409c9ce..6af63d7a9cbe494ee536408e3dd4df5db1d8b0f0 100644 (file)
@@ -103,10 +103,9 @@ int asynchronous_close(int fd) {
                  *
                  * We usually prefer calling waitid(), but before kernel 4.7 it didn't support __WCLONE while
                  * waitpid() did. Hence let's use waitpid() here, it's good enough for our purposes here. */
-                for (;;) {
-                        if (waitpid(pid, NULL, WEXITED|__WCLONE) >= 0 || errno != EINTR)
+                for (;;)
+                        if (waitpid(pid, NULL, __WCLONE) >= 0 || errno != EINTR)
                                 break;
-                }
         }
 
         return -EBADF; /* return an invalidated fd */