]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udevadm-lock: use PidRef 36959/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 2 Apr 2025 14:16:05 +0000 (23:16 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 2 Apr 2025 15:11:27 +0000 (00:11 +0900)
src/udev/udevadm-lock.c

index 78dd43ea45868394a9c8110b366d99b2427333a1..9b495fda3c40232a146d5c627f9314e88d1af81a 100644 (file)
@@ -232,7 +232,6 @@ int lock_main(int argc, char *argv[], void *userdata) {
         _cleanup_free_ dev_t *devnos = NULL;
         size_t n_devnos = 0;
         usec_t deadline;
-        pid_t pid;
         int r;
 
         r = parse_argv(argc, argv);
@@ -290,7 +289,11 @@ int lock_main(int argc, char *argv[], void *userdata) {
         /* Ignore SIGINT and allow the forked process to receive it */
         (void) ignore_signals(SIGINT);
 
-        r = safe_fork("(lock)", FORK_RESET_SIGNALS|FORK_DEATHSIG_SIGTERM|FORK_CLOSE_ALL_FDS|FORK_RLIMIT_NOFILE_SAFE|FORK_LOG, &pid);
+        _cleanup_(pidref_done) PidRef pidref = PIDREF_NULL;
+        r = pidref_safe_fork(
+                        "(lock)",
+                        FORK_RESET_SIGNALS|FORK_DEATHSIG_SIGTERM|FORK_CLOSE_ALL_FDS|FORK_RLIMIT_NOFILE_SAFE|FORK_LOG,
+                        &pidref);
         if (r < 0)
                 return r;
         if (r == 0) {
@@ -302,5 +305,5 @@ int lock_main(int argc, char *argv[], void *userdata) {
                 _exit(EXIT_FAILURE);
         }
 
-        return wait_for_terminate_and_check(arg_cmdline[0], pid, 0);
+        return pidref_wait_for_terminate_and_check(arg_cmdline[0], &pidref, 0);
 }