return log_oom();
key = strjoina(type, "-command");
- (void) serialize_item_format(f, key, "%s %u %s %s", service_exec_command_to_string(id), idx, p, args);
+
+ /* We use '+1234' instead of '1234' to mark the last command in a sequence.
+ * This is used in service_deserialize_exec_command(). */
+ (void) serialize_item_format(
+ f, key,
+ "%s %s%u %s %s",
+ service_exec_command_to_string(id),
+ command->command_next ? "" : "+",
+ idx,
+ p, args);
return 0;
}
Service *s = SERVICE(u);
int r;
unsigned idx = 0, i;
- bool control, found = false;
+ bool control, found = false, last = false;
ServiceExecCommand id = _SERVICE_EXEC_COMMAND_INVALID;
ExecCommand *command = NULL;
_cleanup_free_ char *path = NULL;
state = STATE_EXEC_COMMAND_INDEX;
break;
case STATE_EXEC_COMMAND_INDEX:
+ /* PID 1234 is serialized as either '1234' or '+1234'. The second form is used to
+ * mark the last command in a sequence. We warn if the deserialized command doesn't
+ * match what we have loaded from the unit, but we don't need to warn if that is the
+ * last command. */
+
r = safe_atou(arg, &idx);
if (r < 0)
return r;
+ last = arg[0] == '+';
state = STATE_EXEC_COMMAND_PATH;
break;
s->control_command_id = id;
} else if (command)
s->main_command = command;
+ else if (last)
+ log_unit_debug(u, "Current command vanished from the unit file.");
else
log_unit_warning(u, "Current command vanished from the unit file, execution of the command list won't be resumed.");