chiark / gitweb /
Prep v238: fix forking of the poweroff programs in run_helper()
authorSven Eden <yamakuzure@gmx.net>
Tue, 19 Jun 2018 21:29:56 +0000 (23:29 +0200)
committerSven Eden <yamakuzure@gmx.net>
Fri, 29 Jun 2018 05:12:51 +0000 (07:12 +0200)
src/login/elogind-dbus.c

index fe580696b694004107f219c154c28a07ff8fd33e..715b28b177ec1ced9a0d5a31e192ac1ca040d0f2 100644 (file)
@@ -75,23 +75,21 @@ static int bus_manager_log_shutdown(
 
 /* elogind specific helper to make HALT and REBOOT possible. */
 static int run_helper(const char *helper) {
-        pid_t pid = 0;
         int   r   = 0;
 
-        r = safe_fork_full(helper, NULL, 0, FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_CLOSE_ALL_FDS|FORK_WAIT, &pid);
+        r = safe_fork_full(helper, NULL, 0, FORK_RESET_SIGNALS|FORK_REOPEN_LOG, NULL);
 
         if (r < 0)
                 return log_error_errno(errno, "Failed to fork run %s: %m", helper);
 
-        if (pid == 0) {
+        if (0 == r) {
                 /* Child */
-
                 execlp(helper, helper, NULL);
                 log_error_errno(errno, "Failed to execute %s: %m", helper);
                 _exit(EXIT_FAILURE);
         }
 
-        return r;
+        return 0;
 }
 
 /* elogind specific executor */
@@ -152,7 +150,7 @@ int execute_shutdown_or_sleep(
                 }
 
                  /* This comes from our patched update-utmp/update-utmp.c */
-                update_utmp(2, argv_utmp, m->bus);
+                update_utmp(2, argv_utmp);
                 strv_free(argv_utmp);
         }