chiark / gitweb /
execute: avoid logging to closed fds
[elogind.git] / src / execute.c
index 866e8bf2f69ed9e088e47dea5afd3eebff44d851..065101431d10fa987d81fbbb0625ce45fa0c3c36 100644 (file)
@@ -1016,6 +1016,7 @@ int exec_spawn(ExecCommand *command,
                 /* Close sockets very early to make sure we don't
                  * block init reexecution because it cannot bind its
                  * sockets */
+                log_forget_fds();
                 if (close_all_fds(socket_fd >= 0 ? &socket_fd : fds,
                                   socket_fd >= 0 ? 1 : n_fds) < 0) {
                         r = EXIT_FDS;
@@ -1170,7 +1171,7 @@ int exec_spawn(ExecCommand *command,
                         }
 
                 if (context->utmp_id)
-                        utmp_put_init_process(0, context->utmp_id, getpid(), getsid(0), context->tty_path);
+                        utmp_put_init_process(context->utmp_id, getpid(), getsid(0), context->tty_path);
 
                 if (context->user) {
                         username = context->user;