]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
process-util: make wait_for_terminate() as trivial wrapper of its PidRef version
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 2 Apr 2025 15:08:07 +0000 (00:08 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 2 Apr 2025 15:11:27 +0000 (00:11 +0900)
src/basic/process-util.c
src/basic/process-util.h

index df547ccada3fac0f15c1e71a590bed7f83027deb..d3c43c3ba4e784157f6002d6643c8911d58c56ac 100644 (file)
@@ -879,27 +879,8 @@ int get_process_umask(pid_t pid, mode_t *ret) {
         return parse_mode(m, ret);
 }
 
-int wait_for_terminate(pid_t pid, siginfo_t *status) {
-        siginfo_t dummy;
-
-        assert(pid >= 1);
-
-        if (!status)
-                status = &dummy;
-
-        for (;;) {
-                zero(*status);
-
-                if (waitid(P_PID, pid, status, WEXITED) < 0) {
-
-                        if (errno == EINTR)
-                                continue;
-
-                        return negative_errno();
-                }
-
-                return 0;
-        }
+int wait_for_terminate(pid_t pid, siginfo_t *ret) {
+        return pidref_wait_for_terminate(&PIDREF_MAKE_FROM_PID(pid), ret);
 }
 
 /*
index 910fc604cd3bf043dc29e708e897dd71802489a9..fd24ee41ce2aec8534f45ef3734112988c35f110 100644 (file)
@@ -65,7 +65,7 @@ static inline bool SIGINFO_CODE_IS_DEAD(int code) {
         return IN_SET(code, CLD_EXITED, CLD_KILLED, CLD_DUMPED);
 }
 
-int wait_for_terminate(pid_t pid, siginfo_t *status);
+int wait_for_terminate(pid_t pid, siginfo_t *ret);
 
 typedef enum WaitFlags {
         WAIT_LOG_ABNORMAL             = 1 << 0,