mirror of
https://github.com/systemd/systemd
synced 2024-07-05 17:39:42 +00:00
run: optionally set the "ignore-failure" flag for ExecStart= lines
This commit is contained in:
parent
72eb3081b2
commit
1072d94731
|
@ -485,6 +485,17 @@
|
|||
<xi:include href="version-info.xml" xpointer="v236"/></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--ignore-failure</option></term>
|
||||
|
||||
<listitem><para>By default, if the specified command fails the invoked unit will be marked failed
|
||||
(though possibly still unloaded, see <option>--collect=</option>, above), and this is reported in the
|
||||
logs. If this switch is specified this is suppressed and any non-success exit status/code of the
|
||||
command is treated as success.</para>
|
||||
|
||||
<xi:include href="version-info.xml" xpointer="v256"/></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<xi:include href="user-system-options.xml" xpointer="user" />
|
||||
<xi:include href="user-system-options.xml" xpointer="system" />
|
||||
<xi:include href="user-system-options.xml" xpointer="host" />
|
||||
|
|
|
@ -74,6 +74,7 @@ static char *arg_working_directory = NULL;
|
|||
static bool arg_shell = false;
|
||||
static char **arg_cmdline = NULL;
|
||||
static char *arg_exec_path = NULL;
|
||||
static bool arg_ignore_failure = false;
|
||||
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_description, freep);
|
||||
STATIC_DESTRUCTOR_REGISTER(arg_environment, strv_freep);
|
||||
|
@ -125,6 +126,7 @@ static int help(void) {
|
|||
" -q --quiet Suppress information messages during runtime\n"
|
||||
" -G --collect Unload unit after it ran, even when failed\n"
|
||||
" -S --shell Invoke a $SHELL interactively\n"
|
||||
" --ignore-failure Ignore the exit status of the invoked process\n"
|
||||
"\n%3$sPath options:%4$s\n"
|
||||
" --path-property=NAME=VALUE Set path unit property\n"
|
||||
"\n%3$sSocket options:%4$s\n"
|
||||
|
@ -241,6 +243,7 @@ static int parse_argv(int argc, char *argv[]) {
|
|||
ARG_WAIT,
|
||||
ARG_WORKING_DIRECTORY,
|
||||
ARG_SHELL,
|
||||
ARG_IGNORE_FAILURE,
|
||||
};
|
||||
|
||||
static const struct option options[] = {
|
||||
|
@ -286,6 +289,7 @@ static int parse_argv(int argc, char *argv[]) {
|
|||
{ "working-directory", required_argument, NULL, ARG_WORKING_DIRECTORY },
|
||||
{ "same-dir", no_argument, NULL, 'd' },
|
||||
{ "shell", no_argument, NULL, 'S' },
|
||||
{ "ignore-failure", no_argument, NULL, ARG_IGNORE_FAILURE },
|
||||
{},
|
||||
};
|
||||
|
||||
|
@ -571,6 +575,10 @@ static int parse_argv(int argc, char *argv[]) {
|
|||
arg_shell = true;
|
||||
break;
|
||||
|
||||
case ARG_IGNORE_FAILURE:
|
||||
arg_ignore_failure = true;
|
||||
break;
|
||||
|
||||
case '?':
|
||||
return -EINVAL;
|
||||
|
||||
|
@ -1170,9 +1178,10 @@ static int transient_service_set_properties(sd_bus_message *m, const char *pty_p
|
|||
if (use_ex_prop)
|
||||
r = sd_bus_message_append_strv(
|
||||
m,
|
||||
STRV_MAKE(arg_expand_environment > 0 ? NULL : "no-env-expand"));
|
||||
STRV_MAKE(arg_expand_environment > 0 ? NULL : "no-env-expand",
|
||||
arg_ignore_failure ? "ignore-failure" : NULL));
|
||||
else
|
||||
r = sd_bus_message_append(m, "b", false);
|
||||
r = sd_bus_message_append(m, "b", arg_ignore_failure);
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user