mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-04 17:47:03 +03:00
execute: if the main process of a service already owns the TTY, don't wait for acquiring it again in the reload/stop step
This commit is contained in:
parent
398ef8ba02
commit
1e3ad081ef
@ -232,7 +232,10 @@ static bool is_terminal_input(ExecInput i) {
|
||||
i == EXEC_INPUT_TTY_FAIL;
|
||||
}
|
||||
|
||||
static int fixup_input(ExecInput std_input, int socket_fd) {
|
||||
static int fixup_input(ExecInput std_input, int socket_fd, bool apply_tty_stdin) {
|
||||
|
||||
if (is_terminal_input(std_input) && !apply_tty_stdin)
|
||||
return EXEC_INPUT_NULL;
|
||||
|
||||
if (std_input == EXEC_INPUT_SOCKET && socket_fd < 0)
|
||||
return EXEC_INPUT_NULL;
|
||||
@ -248,12 +251,12 @@ static int fixup_output(ExecOutput std_output, int socket_fd) {
|
||||
return std_output;
|
||||
}
|
||||
|
||||
static int setup_input(const ExecContext *context, int socket_fd) {
|
||||
static int setup_input(const ExecContext *context, int socket_fd, bool apply_tty_stdin) {
|
||||
ExecInput i;
|
||||
|
||||
assert(context);
|
||||
|
||||
i = fixup_input(context->std_input, socket_fd);
|
||||
i = fixup_input(context->std_input, socket_fd, apply_tty_stdin);
|
||||
|
||||
switch (i) {
|
||||
|
||||
@ -289,14 +292,14 @@ static int setup_input(const ExecContext *context, int socket_fd) {
|
||||
}
|
||||
}
|
||||
|
||||
static int setup_output(const ExecContext *context, int socket_fd, const char *ident) {
|
||||
static int setup_output(const ExecContext *context, int socket_fd, const char *ident, bool apply_tty_stdin) {
|
||||
ExecOutput o;
|
||||
ExecInput i;
|
||||
|
||||
assert(context);
|
||||
assert(ident);
|
||||
|
||||
i = fixup_input(context->std_input, socket_fd);
|
||||
i = fixup_input(context->std_input, socket_fd, apply_tty_stdin);
|
||||
o = fixup_output(context->std_output, socket_fd);
|
||||
|
||||
/* This expects the input is already set up */
|
||||
@ -339,14 +342,14 @@ static int setup_output(const ExecContext *context, int socket_fd, const char *i
|
||||
}
|
||||
}
|
||||
|
||||
static int setup_error(const ExecContext *context, int socket_fd, const char *ident) {
|
||||
static int setup_error(const ExecContext *context, int socket_fd, const char *ident, bool apply_tty_stdin) {
|
||||
ExecOutput o, e;
|
||||
ExecInput i;
|
||||
|
||||
assert(context);
|
||||
assert(ident);
|
||||
|
||||
i = fixup_input(context->std_input, socket_fd);
|
||||
i = fixup_input(context->std_input, socket_fd, apply_tty_stdin);
|
||||
o = fixup_output(context->std_output, socket_fd);
|
||||
e = fixup_output(context->std_error, socket_fd);
|
||||
|
||||
@ -889,6 +892,7 @@ int exec_spawn(ExecCommand *command,
|
||||
char **environment,
|
||||
bool apply_permissions,
|
||||
bool apply_chroot,
|
||||
bool apply_tty_stdin,
|
||||
bool confirm_spawn,
|
||||
CGroupBonding *cgroup_bondings,
|
||||
pid_t *ret) {
|
||||
@ -985,7 +989,9 @@ int exec_spawn(ExecCommand *command,
|
||||
}
|
||||
}
|
||||
|
||||
if (confirm_spawn) {
|
||||
/* We skip the confirmation step if we shall not apply the TTY */
|
||||
if (confirm_spawn &&
|
||||
(!is_terminal_input(context->std_input) || apply_tty_stdin)) {
|
||||
char response;
|
||||
|
||||
/* Set up terminal for the question */
|
||||
@ -1018,18 +1024,18 @@ int exec_spawn(ExecCommand *command,
|
||||
}
|
||||
|
||||
if (!keep_stdin)
|
||||
if (setup_input(context, socket_fd) < 0) {
|
||||
if (setup_input(context, socket_fd, apply_tty_stdin) < 0) {
|
||||
r = EXIT_STDIN;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!keep_stdout)
|
||||
if (setup_output(context, socket_fd, file_name_from_path(command->path)) < 0) {
|
||||
if (setup_output(context, socket_fd, file_name_from_path(command->path), apply_tty_stdin) < 0) {
|
||||
r = EXIT_STDOUT;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (setup_error(context, socket_fd, file_name_from_path(command->path)) < 0) {
|
||||
if (setup_error(context, socket_fd, file_name_from_path(command->path), apply_tty_stdin) < 0) {
|
||||
r = EXIT_STDERR;
|
||||
goto fail;
|
||||
}
|
||||
|
@ -196,6 +196,7 @@ int exec_spawn(ExecCommand *command,
|
||||
char **environment,
|
||||
bool apply_permissions,
|
||||
bool apply_chroot,
|
||||
bool apply_tty_stdin,
|
||||
bool confirm_spawn,
|
||||
struct CGroupBonding *cgroup_bondings,
|
||||
pid_t *ret);
|
||||
|
@ -70,7 +70,7 @@ int kmod_setup(void) {
|
||||
command.argv = (char**) cmdline;
|
||||
|
||||
exec_context_init(&context);
|
||||
r = exec_spawn(&command, NULL, &context, NULL, 0, NULL, false, false, false, NULL, &pid);
|
||||
r = exec_spawn(&command, NULL, &context, NULL, 0, NULL, false, false, false, false, NULL, &pid);
|
||||
exec_context_done(&context);
|
||||
|
||||
if (r < 0)
|
||||
|
@ -1273,7 +1273,7 @@ static int transaction_add_job_and_dependencies(
|
||||
assert(unit);
|
||||
|
||||
if (unit->meta.load_state != UNIT_LOADED) {
|
||||
dbus_set_error(e, BUS_ERROR_LOAD_FAILED, "Unit %s failed to load.", unit->meta.id);
|
||||
dbus_set_error(e, BUS_ERROR_LOAD_FAILED, "Unit %s failed to load. See logs for details.", unit->meta.id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -535,6 +535,7 @@ static int mount_spawn(Mount *m, ExecCommand *c, pid_t *_pid) {
|
||||
true,
|
||||
true,
|
||||
m->meta.manager->confirm_spawn,
|
||||
true,
|
||||
m->meta.cgroup_bondings,
|
||||
&pid)) < 0)
|
||||
goto fail;
|
||||
|
@ -1323,6 +1323,7 @@ static int service_spawn(
|
||||
bool pass_fds,
|
||||
bool apply_permissions,
|
||||
bool apply_chroot,
|
||||
bool apply_tty_stdin,
|
||||
bool set_notify_socket,
|
||||
pid_t *_pid) {
|
||||
|
||||
@ -1395,6 +1396,7 @@ static int service_spawn(
|
||||
final_env,
|
||||
apply_permissions,
|
||||
apply_chroot,
|
||||
apply_tty_stdin,
|
||||
s->meta.manager->confirm_spawn,
|
||||
s->meta.cgroup_bondings,
|
||||
&pid);
|
||||
@ -1505,6 +1507,7 @@ static void service_enter_stop_post(Service *s, bool success) {
|
||||
false,
|
||||
!s->permissions_start_only,
|
||||
!s->root_directory_start_only,
|
||||
true,
|
||||
false,
|
||||
&s->control_pid)) < 0)
|
||||
goto fail;
|
||||
@ -1605,6 +1608,7 @@ static void service_enter_stop(Service *s, bool success) {
|
||||
!s->permissions_start_only,
|
||||
!s->root_directory_start_only,
|
||||
false,
|
||||
false,
|
||||
&s->control_pid)) < 0)
|
||||
goto fail;
|
||||
|
||||
@ -1653,6 +1657,7 @@ static void service_enter_start_post(Service *s) {
|
||||
!s->permissions_start_only,
|
||||
!s->root_directory_start_only,
|
||||
false,
|
||||
false,
|
||||
&s->control_pid)) < 0)
|
||||
goto fail;
|
||||
|
||||
@ -1687,6 +1692,7 @@ static void service_enter_start(Service *s) {
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
s->notify_access != NOTIFY_NONE,
|
||||
&pid)) < 0)
|
||||
goto fail;
|
||||
@ -1747,6 +1753,7 @@ static void service_enter_start_pre(Service *s) {
|
||||
false,
|
||||
!s->permissions_start_only,
|
||||
!s->root_directory_start_only,
|
||||
true,
|
||||
false,
|
||||
&s->control_pid)) < 0)
|
||||
goto fail;
|
||||
@ -1800,6 +1807,7 @@ static void service_enter_reload(Service *s) {
|
||||
!s->permissions_start_only,
|
||||
!s->root_directory_start_only,
|
||||
false,
|
||||
false,
|
||||
&s->control_pid)) < 0)
|
||||
goto fail;
|
||||
|
||||
@ -1835,6 +1843,7 @@ static void service_run_next(Service *s, bool success) {
|
||||
!s->permissions_start_only,
|
||||
!s->root_directory_start_only,
|
||||
false,
|
||||
false,
|
||||
&s->control_pid)) < 0)
|
||||
goto fail;
|
||||
|
||||
|
@ -822,6 +822,7 @@ static int socket_spawn(Socket *s, ExecCommand *c, pid_t *_pid) {
|
||||
s->meta.manager->environment,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
s->meta.manager->confirm_spawn,
|
||||
s->meta.cgroup_bondings,
|
||||
&pid);
|
||||
|
Loading…
x
Reference in New Issue
Block a user