summaryrefslogtreecommitdiff
path: root/src/core/execute.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-04-24 14:28:00 +0200
committerLennart Poettering <lennart@poettering.net>2012-04-24 14:42:24 +0200
commitf2b6878955b1f77ea1fa87b502b13d5dbefc57f6 (patch)
tree3fdf72d167a9e64ac16aaac52eaffa57c3cb9d13 /src/core/execute.c
parent8d8e945624a0080073d94941f3032b8fa3b3aa15 (diff)
service: introduce Type=idle and use it for gettys
Type=idle is much like Type=simple, however between the fork() and the exec() in the child we wait until PID 1 informs us that no jobs are left. This is mostly a cosmetic fix to make gettys appear only after all boot output is finished and complete. Note that this does not impact the normal job logic as we do not delay the completion of any jobs. We just delay the invocation of the actual binary, and only for services that otherwise would be of Type=simple.
Diffstat (limited to 'src/core/execute.c')
-rw-r--r--src/core/execute.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/execute.c b/src/core/execute.c
index c59f7e2daa..99a7881f1c 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -37,6 +37,7 @@
#include <sys/mount.h>
#include <linux/fs.h>
#include <linux/oom.h>
+#include <sys/poll.h>
#ifdef HAVE_PAM
#include <security/pam_appl.h>
@@ -963,6 +964,7 @@ int exec_spawn(ExecCommand *command,
CGroupBonding *cgroup_bondings,
CGroupAttribute *cgroup_attributes,
const char *cgroup_suffix,
+ int idle_pipe[2],
pid_t *ret) {
pid_t pid;
@@ -1050,6 +1052,15 @@ int exec_spawn(ExecCommand *command,
goto fail_child;
}
+ if (idle_pipe) {
+ if (idle_pipe[1] >= 0)
+ close_nointr_nofail(idle_pipe[1]);
+ if (idle_pipe[0] >= 0) {
+ fd_wait_for_event(idle_pipe[0], POLLHUP, DEFAULT_TIMEOUT_USEC);
+ close_nointr_nofail(idle_pipe[0]);
+ }
+ }
+
/* Close sockets very early to make sure we don't
* block init reexecution because it cannot bind its
* sockets */