s->main_pid_alien = false;
s->forbid_restart = false;
+ free(s->status_text);
+ s->status_text = NULL;
+ s->status_errno = 0;
+
service_enter_start_pre(s);
return 0;
}
}
if (s->notify_access == NOTIFY_MAIN && pid != s->main_pid) {
-
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
}
/* Interpret MAINPID= */
- if ((e = strv_find_prefix(tags, "MAINPID=")) &&
- (s->state == SERVICE_START ||
- s->state == SERVICE_START_POST ||
- s->state == SERVICE_RUNNING ||
- s->state == SERVICE_RELOAD)) {
-
+ e = strv_find_prefix(tags, "MAINPID=");
+ if (e && IN_SET(s->state, SERVICE_START, SERVICE_START_POST, SERVICE_RUNNING, SERVICE_RELOAD)) {
if (parse_pid(e + 8, &pid) < 0)
- log_warning_unit(u->id, "Failed to parse notification message %s", e);
+ log_warning_unit(u->id, "Failed to parse MAINPID= field in notification message: %s", e);
else {
log_debug_unit(u->id, "%s: got %s", u->id, e);
service_set_main_pid(s, pid);
free(t);
}
+ /* Interpret ERRNO= */
+ e = strv_find_prefix(tags, "ERRNO=");
+ if (e) {
+ int status_errno;
+
+ if (safe_atoi(e + 6, &status_errno) < 0 || status_errno < 0)
+ log_warning_unit(u->id, "Failed to parse ERRNO= field in notification message: %s", e);
+ else {
+ log_debug_unit(u->id, "%s: got %s", u->id, e);
+
+ if (s->status_errno != status_errno) {
+ s->status_errno = status_errno;
+ notify_dbus = true;
+ }
+ }
+ }
+
/* Interpret WATCHDOG= */
if (strv_find(tags, "WATCHDOG=1")) {
log_debug_unit(u->id, "%s: got WATCHDOG=1", u->id);