|
|
a4b143 |
From f47d0b042f6d0a1661dff9816410162693d1daa2 Mon Sep 17 00:00:00 2001
|
|
|
a4b143 |
From: Lennart Poettering <lennart@poettering.net>
|
|
|
a4b143 |
Date: Tue, 1 Oct 2013 05:06:56 +0200
|
|
|
a4b143 |
Subject: [PATCH] core: whenever a new PID is passed to us, make sure we watch
|
|
|
a4b143 |
it
|
|
|
a4b143 |
|
|
|
a4b143 |
---
|
|
|
a4b143 |
src/core/service.c | 21 +++++++++++++++------
|
|
|
a4b143 |
1 file changed, 15 insertions(+), 6 deletions(-)
|
|
|
a4b143 |
|
|
|
a4b143 |
diff --git a/src/core/service.c b/src/core/service.c
|
|
|
a4b143 |
index 246a86e..5953f45 100644
|
|
|
a4b143 |
--- a/src/core/service.c
|
|
|
a4b143 |
+++ b/src/core/service.c
|
|
|
a4b143 |
@@ -191,7 +191,13 @@ static int service_set_main_pid(Service *s, pid_t pid) {
|
|
|
a4b143 |
if (pid == getpid())
|
|
|
a4b143 |
return -EINVAL;
|
|
|
a4b143 |
|
|
|
a4b143 |
- service_unwatch_main_pid(s);
|
|
|
a4b143 |
+ if (s->main_pid == pid && s->main_pid_known)
|
|
|
a4b143 |
+ return 0;
|
|
|
a4b143 |
+
|
|
|
a4b143 |
+ if (s->main_pid != pid) {
|
|
|
a4b143 |
+ service_unwatch_main_pid(s);
|
|
|
a4b143 |
+ exec_status_start(&s->main_exec_status, pid);
|
|
|
a4b143 |
+ }
|
|
|
a4b143 |
|
|
|
a4b143 |
s->main_pid = pid;
|
|
|
a4b143 |
s->main_pid_known = true;
|
|
|
a4b143 |
@@ -205,8 +211,6 @@ static int service_set_main_pid(Service *s, pid_t pid) {
|
|
|
a4b143 |
} else
|
|
|
a4b143 |
s->main_pid_alien = false;
|
|
|
a4b143 |
|
|
|
a4b143 |
- exec_status_start(&s->main_exec_status, pid);
|
|
|
a4b143 |
-
|
|
|
a4b143 |
return 0;
|
|
|
a4b143 |
}
|
|
|
a4b143 |
|
|
|
a4b143 |
@@ -2698,8 +2702,10 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
|
|
|
a4b143 |
|
|
|
a4b143 |
if (parse_pid(value, &pid) < 0)
|
|
|
a4b143 |
log_debug_unit(u->id, "Failed to parse main-pid value %s", value);
|
|
|
a4b143 |
- else
|
|
|
a4b143 |
- service_set_main_pid(s, (pid_t) pid);
|
|
|
a4b143 |
+ else {
|
|
|
a4b143 |
+ service_set_main_pid(s, pid);
|
|
|
a4b143 |
+ unit_watch_pid(UNIT(s), pid);
|
|
|
a4b143 |
+ }
|
|
|
a4b143 |
} else if (streq(key, "main-pid-known")) {
|
|
|
a4b143 |
int b;
|
|
|
a4b143 |
|
|
|
a4b143 |
@@ -3391,6 +3397,7 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
|
|
|
a4b143 |
log_debug_unit(u->id,
|
|
|
a4b143 |
"%s: got %s", u->id, e);
|
|
|
a4b143 |
service_set_main_pid(s, pid);
|
|
|
a4b143 |
+ unit_watch_pid(UNIT(s), pid);
|
|
|
a4b143 |
}
|
|
|
a4b143 |
}
|
|
|
a4b143 |
|
|
|
a4b143 |
@@ -3687,8 +3694,10 @@ static void service_bus_query_pid_done(
|
|
|
a4b143 |
(s->state == SERVICE_START ||
|
|
|
a4b143 |
s->state == SERVICE_START_POST ||
|
|
|
a4b143 |
s->state == SERVICE_RUNNING ||
|
|
|
a4b143 |
- s->state == SERVICE_RELOAD))
|
|
|
a4b143 |
+ s->state == SERVICE_RELOAD)){
|
|
|
a4b143 |
service_set_main_pid(s, pid);
|
|
|
a4b143 |
+ unit_watch_pid(UNIT(s), pid);
|
|
|
a4b143 |
+ }
|
|
|
a4b143 |
}
|
|
|
a4b143 |
|
|
|
a4b143 |
int service_set_socket_fd(Service *s, int fd, Socket *sock) {
|