summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
0cdad5c)
Warn if a service promises to write a PID file (using 'PIDFile=' in the
unit file or '# pidfile:' in SysV header), but fails to keep the
promise.
This warning will likely trigger also for the forking services with a
racy daemonization, which exit the original process before the PID file
is written.
-static int service_load_pid_file(Service *s) {
+static int service_load_pid_file(Service *s, bool warn_if_missing) {
char *k;
int r;
pid_t pid;
char *k;
int r;
pid_t pid;
if (!s->pid_file)
return -ENOENT;
if (!s->pid_file)
return -ENOENT;
- if ((r = read_one_line_file(s->pid_file, &k)) < 0)
+ if ((r = read_one_line_file(s->pid_file, &k)) < 0) {
+ if (warn_if_missing)
+ log_warning("Failed to read PID file %s after %s. The service might be broken.",
+ s->pid_file, service_state_to_string(s->state));
r = parse_pid(k, &pid);
free(k);
r = parse_pid(k, &pid);
free(k);
/* Forking services may occasionally move to a new PID.
* As long as they update the PID file before exiting the old
* PID, they're fine. */
/* Forking services may occasionally move to a new PID.
* As long as they update the PID file before exiting the old
* PID, they're fine. */
- if (service_load_pid_file(s) == 0)
+ if (service_load_pid_file(s, false) == 0)
* START_POST script */
if (success) {
* START_POST script */
if (success) {
- service_load_pid_file(s);
+ service_load_pid_file(s, !s->exec_command[SERVICE_EXEC_START_POST]);
service_search_main_pid(s);
service_enter_start_post(s);
service_search_main_pid(s);
service_enter_start_post(s);
case SERVICE_START_POST:
if (success) {
case SERVICE_START_POST:
if (success) {
- service_load_pid_file(s);
+ service_load_pid_file(s, true);
service_search_main_pid(s);
}
service_search_main_pid(s);
}
case SERVICE_RELOAD:
if (success) {
case SERVICE_RELOAD:
if (success) {
- service_load_pid_file(s);
+ service_load_pid_file(s, true);
service_search_main_pid(s);
}
service_search_main_pid(s);
}