summaryrefslogtreecommitdiff
path: root/src/service.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-02-13 18:51:30 +0100
committerLennart Poettering <lennart@poettering.net>2011-02-13 18:51:30 +0100
commit3185a36b05d53757a412f847d8c510978b9b00f0 (patch)
tree14e95eaae6c7dc0ecfc4486efbbbb9446e4be0ed /src/service.c
parente9fbc77c8f6a396ce9432e3791710e30de6e570b (diff)
service: make main pid guessing optional, and reread pid file after reloads
Diffstat (limited to 'src/service.c')
-rw-r--r--src/service.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/service.c b/src/service.c
index 60576dfed7..243e5536a7 100644
--- a/src/service.c
+++ b/src/service.c
@@ -118,6 +118,7 @@ static void service_init(Unit *u) {
s->sysv_start_priority = -1;
#endif
s->socket_fd = -1;
+ s->guess_main_pid = true;
exec_context_init(&s->exec_context);
@@ -1151,6 +1152,7 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
"%sPermissionsStartOnly: %s\n"
"%sRootDirectoryStartOnly: %s\n"
"%sRemainAfterExit: %s\n"
+ "%sGuessMainPID: %s\n"
"%sType: %s\n"
"%sRestart: %s\n"
"%sNotifyAccess: %s\n",
@@ -1158,6 +1160,7 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
prefix, yes_no(s->permissions_start_only),
prefix, yes_no(s->root_directory_start_only),
prefix, yes_no(s->remain_after_exit),
+ prefix, yes_no(s->guess_main_pid),
prefix, service_type_to_string(s->type),
prefix, service_restart_to_string(s->restart),
prefix, notify_access_to_string(s->notify_access));
@@ -1236,11 +1239,6 @@ static int service_load_pid_file(Service *s) {
assert(s);
- if (s->main_pid_known)
- return 0;
-
- assert(s->main_pid <= 0);
-
if (!s->pid_file)
return -ENOENT;
@@ -1275,9 +1273,14 @@ static int service_search_main_pid(Service *s) {
assert(s);
+ /* If we know it anyway, don't ever fallback to unreliable
+ * heuristics */
if (s->main_pid_known)
return 0;
+ if (!s->guess_main_pid)
+ return 0;
+
assert(s->main_pid <= 0);
if ((pid = cgroup_bonding_search_main_pid_list(s->meta.cgroup_bondings)) <= 0)
@@ -2674,9 +2677,16 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
log_warning("%s: failed to load PID file %s: %s", s->meta.id, s->pid_file, strerror(-r));
}
- /* Fall through */
+ s->reload_failure = !success;
+ service_enter_running(s, true);
+ break;
case SERVICE_RELOAD:
+ if (success) {
+ service_load_pid_file(s);
+ service_search_main_pid(s);
+ }
+
s->reload_failure = !success;
service_enter_running(s, true);
break;