X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fservice.c;h=6fc2484f1321be2cc2d274bb932ca36d12f644a3;hb=75d3fc60f88e08bf953063819a8a04b881d6db23;hp=c2053ce3ac45e8d829bc232e28c52e4e61f748a2;hpb=4e2b0f9b149e6fc1adb5ce49a6adaeed130577be;p=elogind.git diff --git a/src/service.c b/src/service.c index c2053ce3a..6fc2484f1 100644 --- a/src/service.c +++ b/src/service.c @@ -83,7 +83,7 @@ static const struct { #define RUNLEVELS_UP "12345" /* #define RUNLEVELS_DOWN "06" */ -/* #define RUNLEVELS_BOOT "bBsS" */ +#define RUNLEVELS_BOOT "bBsS" #endif static const UnitActiveState state_translation_table[_SERVICE_STATE_MAX] = { @@ -277,7 +277,8 @@ static int sysv_translate_facility(const char *name, const char *filename, char static const char * const table[] = { /* LSB defined facilities */ "local_fs", SPECIAL_LOCAL_FS_TARGET, -#ifndef TARGET_MANDRIVA +#if defined(TARGET_MANDRIVA) || defined(TARGET_MAGEIA) +#else /* Due to unfortunate name selection in Mandriva, * $network is provided by network-up which is ordered * after network which actually starts interfaces. @@ -811,6 +812,13 @@ static int service_load_sysv_path(Service *s, const char *path) { if ((r = sysv_exec_commands(s)) < 0) goto finish; + if (s->sysv_runlevels && + chars_intersect(RUNLEVELS_BOOT, s->sysv_runlevels) && + chars_intersect(RUNLEVELS_UP, s->sysv_runlevels)) { + /* Service has both boot and "up" runlevels + configured. Kill the "up" ones. */ + delete_chars(s->sysv_runlevels, RUNLEVELS_UP); + } if (s->sysv_runlevels && !chars_intersect(RUNLEVELS_UP, s->sysv_runlevels)) { /* If there a runlevels configured for this service @@ -829,6 +837,7 @@ static int service_load_sysv_path(Service *s, const char *path) { /* Special setting for all SysV services */ s->type = SERVICE_FORKING; s->remain_after_exit = !s->pid_file; + s->guess_main_pid = false; s->restart = SERVICE_RESTART_NO; if (s->meta.manager->sysv_console) @@ -1281,7 +1290,7 @@ static void service_dump(Unit *u, FILE *f, const char *prefix) { 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; int r; pid_t pid; @@ -1292,7 +1301,7 @@ static int service_load_pid_file(Service *s, bool warn_if_missing) { return -ENOENT; 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.", s->pid_file, service_state_to_string(s->state)); return r; @@ -1305,8 +1314,9 @@ static int service_load_pid_file(Service *s, bool warn_if_missing) { return r; if (kill(pid, 0) < 0 && errno != EPERM) { - 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); + if (may_warn) + 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); return -ESRCH; }