From f7b1d37c779ac0ae2314d25c8c88db409a425c9d Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Tue, 11 Jul 2023 12:06:14 +0800 Subject: [PATCH 1/2] shared/async: prefix process name with sd- --- src/shared/async.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/async.c b/src/shared/async.c index b7ecb9c4b7..1cf1936d4b 100644 --- a/src/shared/async.c +++ b/src/shared/async.c @@ -41,7 +41,7 @@ int asynchronous_sync(pid_t *ret_pid) { static int close_func(void *p) { unsigned v = PTR_TO_UINT(p); - (void) prctl(PR_SET_NAME, (unsigned long*) "(close)"); + (void) prctl(PR_SET_NAME, (unsigned long*) "(sd-close)"); /* Note: 💣 This function is invoked in a child process created via glibc's clone() wrapper. In such * children memory allocation is not allowed, since glibc does not release malloc mutexes in From 898f4da326051addf1ec17887e6b1737d0dab2ec Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Tue, 11 Jul 2023 01:46:29 +0800 Subject: [PATCH 2/2] shared/async: don't use WEXITED for waitpid() 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 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/shared/async.c b/src/shared/async.c index 1cf1936d4b..6af63d7a9c 100644 --- a/src/shared/async.c +++ b/src/shared/async.c @@ -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 */