X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fcore%2Fservice.c;h=ca71788d220a55b40349025b65298237a7bb57a7;hp=5c6b638650198a1575ef944786e1344570c99a90;hb=454f7158c6cecd18555c5e7dd556e3d544301b52;hpb=336c6e4690ea017a11799aa331ffedd4c59a31ad diff --git a/src/core/service.c b/src/core/service.c index 5c6b63865..ca71788d2 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -264,7 +264,7 @@ static void service_start_watchdog(Service *s) { r = sd_event_source_set_enabled(s->watchdog_event_source, SD_EVENT_ONESHOT); } else { - r = sd_event_add_monotonic(UNIT(s)->manager->event, s->watchdog_timestamp.monotonic + s->watchdog_usec, 0, service_dispatch_watchdog, s, &s->watchdog_event_source); + r = sd_event_add_monotonic(UNIT(s)->manager->event, &s->watchdog_event_source, s->watchdog_timestamp.monotonic + s->watchdog_usec, 0, service_dispatch_watchdog, s); if (r < 0) { log_warning_unit(UNIT(s)->id, "%s failed to add watchdog timer: %s", UNIT(s)->id, strerror(-r)); return; @@ -354,7 +354,7 @@ static int service_arm_timer(Service *s, usec_t usec) { return sd_event_source_set_enabled(s->timer_event_source, SD_EVENT_ONESHOT); } - return sd_event_add_monotonic(UNIT(s)->manager->event, now(CLOCK_MONOTONIC) + usec, 0, service_dispatch_timer, s, &s->timer_event_source); + return sd_event_add_monotonic(UNIT(s)->manager->event, &s->timer_event_source, now(CLOCK_MONOTONIC) + usec, 0, service_dispatch_timer, s); } #ifdef HAVE_SYSV_COMPAT @@ -1368,11 +1368,10 @@ static int service_load_pid_file(Service *s, bool may_warn) { return r; } - if (kill(pid, 0) < 0 && errno != EPERM) { + if (!pid_is_alive(pid)) { if (may_warn) - log_info_unit(UNIT(s)->id, - "PID "PID_FMT" read from file %s does not exist.", - pid, s->pid_file); + log_info_unit(UNIT(s)->id, "PID "PID_FMT" read from file %s does not exist or is a zombie.", pid, s->pid_file); + return -ESRCH; } @@ -1565,7 +1564,7 @@ static int service_coldplug(Unit *u) { return r; } - if (pid_valid(s->main_pid) && + if (pid_is_unwaited(s->main_pid) && ((s->deserialized_state == SERVICE_START && IN_SET(s->type, SERVICE_FORKING, SERVICE_DBUS, SERVICE_ONESHOT, SERVICE_NOTIFY)) || IN_SET(s->deserialized_state, SERVICE_START, SERVICE_START_POST, @@ -1578,7 +1577,7 @@ static int service_coldplug(Unit *u) { return r; } - if (pid_valid(s->control_pid) && + if (pid_is_unwaited(s->control_pid) && IN_SET(s->deserialized_state, SERVICE_START_PRE, SERVICE_START, SERVICE_START_POST, SERVICE_RELOAD, @@ -1810,7 +1809,7 @@ static int main_pid_good(Service *s) { /* If it's an alien child let's check if it is still * alive ... */ if (s->main_pid_alien && s->main_pid > 0) - return kill(s->main_pid, 0) >= 0 || errno != ESRCH; + return pid_is_alive(s->main_pid); /* .. otherwise assume we'll get a SIGCHLD for it, * which we really should wait for to collect exit @@ -3309,7 +3308,10 @@ static int service_dispatch_timer(sd_event_source *source, usec_t usec, void *us case SERVICE_AUTO_RESTART: log_info_unit(UNIT(s)->id, - "%s holdoff time over, scheduling restart.", UNIT(s)->id); + s->restart_usec > 0 ? + "%s holdoff time over, scheduling restart." : + "%s has no holdoff time, scheduling restart.", + UNIT(s)->id); service_enter_restart(s); break; @@ -3354,7 +3356,7 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) { if (s->main_pid != 0) log_warning_unit(u->id, "%s: Got notification message from PID "PID_FMT", but reception only permitted for main PID "PID_FMT, u->id, pid, s->main_pid); else - log_warning_unit(u->id, "%s: Got notification message from PID "PID_FMT", but reception only permitted for main PID which is currently not known", u->id, pid); + log_debug_unit(u->id, "%s: Got notification message from PID "PID_FMT", but reception only permitted for main PID which is currently not known", u->id, pid); return; }