mirror of
https://github.com/systemd/systemd.git
synced 2024-11-07 01:27:11 +03:00
service: don't warn if the pidfile still exists after SIGCHLD
A service that drops its privileges may not be able to remove it when it exits. The stale pidfile is not a problem as long as the service carefully recognizes it on its next start. systemd would produce a warning after the service exits: PID ... read from file ... does not exist. Your service or init script might be broken. Silence the warning in this case. Still warn if this error is detected when loading the pidfile after service start. Noticed by Miroslav Lichvar in https://bugzilla.redhat.com/show_bug.cgi?id=752396
This commit is contained in:
parent
42c3673e63
commit
c5419d4239
@ -1290,7 +1290,7 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) {
|
|||||||
free(p2);
|
free(p2);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int service_load_pid_file(Service *s, bool warn_if_missing) {
|
static int service_load_pid_file(Service *s, bool may_warn) {
|
||||||
char *k;
|
char *k;
|
||||||
int r;
|
int r;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
@ -1301,7 +1301,7 @@ static int service_load_pid_file(Service *s, bool warn_if_missing) {
|
|||||||
return -ENOENT;
|
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)
|
if (may_warn)
|
||||||
log_warning("Failed to read PID file %s after %s. The service might be broken.",
|
log_warning("Failed to read PID file %s after %s. The service might be broken.",
|
||||||
s->pid_file, service_state_to_string(s->state));
|
s->pid_file, service_state_to_string(s->state));
|
||||||
return r;
|
return r;
|
||||||
@ -1314,6 +1314,7 @@ static int service_load_pid_file(Service *s, bool warn_if_missing) {
|
|||||||
return r;
|
return r;
|
||||||
|
|
||||||
if (kill(pid, 0) < 0 && errno != EPERM) {
|
if (kill(pid, 0) < 0 && errno != EPERM) {
|
||||||
|
if (may_warn)
|
||||||
log_warning("PID %lu read from file %s does not exist. Your service or init script might be broken.",
|
log_warning("PID %lu read from file %s does not exist. Your service or init script might be broken.",
|
||||||
(unsigned long) pid, s->pid_file);
|
(unsigned long) pid, s->pid_file);
|
||||||
return -ESRCH;
|
return -ESRCH;
|
||||||
|
Loading…
Reference in New Issue
Block a user