diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-07-08 04:09:17 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-07-08 04:09:17 +0200 |
commit | 1e3ad081efda42dd1cc737ce7e98be8889c78340 (patch) | |
tree | 95e2dab095999baa69ad62d413e72b318daf8760 | |
parent | 398ef8ba0266cca453d90a90b3a2aa1caa44189f (diff) |
execute: if the main process of a service already owns the TTY, don't wait for acquiring it again in the reload/stop step
-rw-r--r-- | src/execute.c | 28 | ||||
-rw-r--r-- | src/execute.h | 1 | ||||
-rw-r--r-- | src/kmod-setup.c | 2 | ||||
-rw-r--r-- | src/manager.c | 2 | ||||
-rw-r--r-- | src/mount.c | 1 | ||||
-rw-r--r-- | src/service.c | 9 | ||||
-rw-r--r-- | src/socket.c | 1 |
7 files changed, 31 insertions, 13 deletions
diff --git a/src/execute.c b/src/execute.c index d7239d5440..138d38817f 100644 --- a/src/execute.c +++ b/src/execute.c @@ -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; } diff --git a/src/execute.h b/src/execute.h index 2e0e6cca3c..a9075fe0eb 100644 --- a/src/execute.h +++ b/src/execute.h @@ -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); diff --git a/src/kmod-setup.c b/src/kmod-setup.c index e3925c5ac9..3ce6fcc77b 100644 --- a/src/kmod-setup.c +++ b/src/kmod-setup.c @@ -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) diff --git a/src/manager.c b/src/manager.c index 9cbf9c8748..adff546397 100644 --- a/src/manager.c +++ b/src/manager.c @@ -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; } diff --git a/src/mount.c b/src/mount.c index 50fe85cb7c..e7fdcc84f3 100644 --- a/src/mount.c +++ b/src/mount.c @@ -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; diff --git a/src/service.c b/src/service.c index 75439be376..2ca0c17ec2 100644 --- a/src/service.c +++ b/src/service.c @@ -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; diff --git a/src/socket.c b/src/socket.c index b8643d9f43..ee75de04d6 100644 --- a/src/socket.c +++ b/src/socket.c @@ -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); |