summaryrefslogtreecommitdiff
path: root/src/service.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-10-27 03:16:49 +0200
committerLennart Poettering <lennart@poettering.net>2010-10-27 03:16:49 +0200
commit4fbf50b38e847aaa2932ac542e20c62f0c1605a3 (patch)
tree821c1cbd6d883b277940d5eb8db64d2365132bd9 /src/service.c
parent10717a1a8d48e50463abf2f6b47e2618eaa529e7 (diff)
service: when after startup only one process is in a service's cgroup, assume it is the main process
Diffstat (limited to 'src/service.c')
-rw-r--r--src/service.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/service.c b/src/service.c
index 46d7bbb1c7..5cf78966a1 100644
--- a/src/service.c
+++ b/src/service.c
@@ -1220,6 +1220,30 @@ static int service_load_pid_file(Service *s) {
return 0;
}
+static int service_search_main_pid(Service *s) {
+ pid_t pid;
+ int r;
+
+ assert(s);
+
+ if (s->main_pid_known)
+ return 0;
+
+ assert(s->main_pid <= 0);
+
+ if ((pid = cgroup_bonding_search_main_pid_list(s->meta.cgroup_bondings)) <= 0)
+ return -ENOENT;
+
+ if ((r = service_set_main_pid(s, pid)) < 0)
+ return r;
+
+ if ((r = unit_watch_pid(UNIT(s), pid)) < 0)
+ /* FIXME: we need to do something here */
+ return r;
+
+ return 0;
+}
+
static int service_get_sockets(Service *s, Set **_set) {
Set *set;
Iterator i;
@@ -2595,8 +2619,8 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
* START_POST script */
if (success) {
- if (s->pid_file)
- service_load_pid_file(s);
+ service_load_pid_file(s);
+ service_search_main_pid(s);
service_enter_start_post(s);
} else