X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fservice.c;h=ecfd054105a2b07fa4784554711773158d17c68e;hp=d6897341645c057d0ff2cb01670a0d777e9b7d5e;hb=ecdbca40bd985f269cd77fc122a648630f330c28;hpb=9e58ff9c5c3bd46a796a20fc6c304cdab489f334 diff --git a/src/service.c b/src/service.c index d68973416..ecfd05410 100644 --- a/src/service.c +++ b/src/service.c @@ -457,7 +457,8 @@ static int service_load_sysv_path(Service *s, const char *path) { s->sysv_runlevels = d; } - } else if (startswith_no_case(t, "description:")) { + } else if (startswith_no_case(t, "description:") && + !u->meta.description) { size_t k = strlen(t); char *d; @@ -603,9 +604,13 @@ static int service_load_sysv_path(Service *s, const char *path) { s->sysv_runlevels = d; } - } else if (startswith_no_case(t, "Description:")) { + } else if (startswith_no_case(t, "Description:") && + !u->meta.description) { char *d; + /* We use the long description only if + * no short description is set. */ + state = LSB_DESCRIPTION; if (!(d = strdup(strstrip(t+12)))) { @@ -616,13 +621,9 @@ static int service_load_sysv_path(Service *s, const char *path) { free(u->meta.description); u->meta.description = d; - } else if (startswith_no_case(t, "Short-Description:") && - !u->meta.description) { + } else if (startswith_no_case(t, "Short-Description:")) { char *d; - /* We use the short description only - * if no long description is set. */ - state = LSB; if (!(d = strdup(strstrip(t+18)))) { @@ -1971,6 +1972,28 @@ static int service_serialize(Unit *u, FILE *f, FDSet *fds) { unit_serialize_item_format(u, f, "socket-fd", "%i", copy); } + if (s->main_exec_status.pid > 0) { + unit_serialize_item_format(u, f, "main-exec-status-pid", "%lu", (unsigned long) s->main_exec_status.pid); + + if (s->main_exec_status.start_timestamp.realtime > 0) { + unit_serialize_item_format(u, f, "main-exec-status-start-realtime", + "%llu", (unsigned long long) s->main_exec_status.start_timestamp.realtime); + + unit_serialize_item_format(u, f, "main-exec-status-start-monotonic", + "%llu", (unsigned long long) s->main_exec_status.start_timestamp.monotonic); + } + + if (s->main_exec_status.exit_timestamp.realtime > 0) { + unit_serialize_item_format(u, f, "main-exec-status-exit-realtime", + "%llu", (unsigned long long) s->main_exec_status.exit_timestamp.realtime); + unit_serialize_item_format(u, f, "main-exec-status-exit-monotonic", + "%llu", (unsigned long long) s->main_exec_status.exit_timestamp.monotonic); + + unit_serialize_item_format(u, f, "main-exec-status-code", "%i", s->main_exec_status.code); + unit_serialize_item_format(u, f, "main-exec-status-status", "%i", s->main_exec_status.status); + } + } + return 0; } @@ -2038,6 +2061,55 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value, close_nointr_nofail(s->socket_fd); s->socket_fd = fdset_remove(fds, fd); } + } else if (streq(key, "main-exec-status-pid")) { + pid_t pid; + + if ((r = parse_pid(value, &pid)) < 0) + log_debug("Failed to parse main-exec-status-pid value %s", value); + else + s->main_exec_status.pid = pid; + } else if (streq(key, "main-exec-status-code")) { + int i; + + if ((r = safe_atoi(value, &i)) < 0) + log_debug("Failed to parse main-exec-status-code value %s", value); + else + s->main_exec_status.code = i; + } else if (streq(key, "main-exec-status-status")) { + int i; + + if ((r = safe_atoi(value, &i)) < 0) + log_debug("Failed to parse main-exec-status-status value %s", value); + else + s->main_exec_status.status = i; + } else if (streq(key, "main-exec-status-start-realtime")) { + uint64_t k; + + if ((r = safe_atollu(value, &k)) < 0) + log_debug("Failed to parse main-exec-status-start-realtime value %s", value); + else + s->main_exec_status.start_timestamp.realtime = (usec_t) k; + } else if (streq(key, "main-exec-status-start-monotonic")) { + uint64_t k; + + if ((r = safe_atollu(value, &k)) < 0) + log_debug("Failed to parse main-exec-status-start-monotonic value %s", value); + else + s->main_exec_status.start_timestamp.monotonic = (usec_t) k; + } else if (streq(key, "main-exec-status-exit-realtime")) { + uint64_t k; + + if ((r = safe_atollu(value, &k)) < 0) + log_debug("Failed to parse main-exec-status-exit-realtime value %s", value); + else + s->main_exec_status.exit_timestamp.realtime = (usec_t) k; + } else if (streq(key, "main-exec-status-exit-monotonic")) { + uint64_t k; + + if ((r = safe_atollu(value, &k)) < 0) + log_debug("Failed to parse main-exec-status-exit-monotonic value %s", value); + else + s->main_exec_status.exit_timestamp.monotonic = (usec_t) k; } else log_debug("Unknown serialization key '%s'", key);