core: do not touch tty when StandardOutput=/StandardError=journal+console/kmsg+console
This commit is contained in:
@@ -4860,7 +4860,7 @@ static void prepare_terminal(
|
||||
assert(p);
|
||||
|
||||
/* We only try to reset things if we there's the chance our stdout points to a TTY */
|
||||
if (!(exec_output_is_terminal(context->std_output) ||
|
||||
if (!(context->std_output == EXEC_OUTPUT_TTY ||
|
||||
(context->std_output == EXEC_OUTPUT_INHERIT && exec_input_is_terminal(context->std_input)) ||
|
||||
context->std_output == EXEC_OUTPUT_NAMED_FD ||
|
||||
p->stdout_fd >= 0))
|
||||
@@ -4901,10 +4901,7 @@ static int setup_term_environment(const ExecContext *context, char ***env) {
|
||||
return 0;
|
||||
|
||||
/* Do we need $TERM at all? */
|
||||
if (!exec_input_is_terminal(context->std_input) &&
|
||||
!exec_output_is_terminal(context->std_output) &&
|
||||
!exec_output_is_terminal(context->std_error) &&
|
||||
!context->tty_path)
|
||||
if (!exec_context_has_tty(context))
|
||||
return 0;
|
||||
|
||||
const char *tty_path = exec_context_tty_path(context);
|
||||
|
||||
+3
-4
@@ -137,8 +137,7 @@ void exec_context_tty_reset(const ExecContext *context, const ExecParameters *pa
|
||||
|
||||
if (parameters && parameters->stdout_fd >= 0 && isatty_safe(parameters->stdout_fd))
|
||||
fd = parameters->stdout_fd;
|
||||
else if (path && (context->tty_path || exec_input_is_terminal(context->std_input) ||
|
||||
exec_output_is_terminal(context->std_output) || exec_output_is_terminal(context->std_error))) {
|
||||
else if (path && exec_context_has_tty(context)) {
|
||||
fd = _fd = open_terminal(path, O_RDWR|O_NOCTTY|O_CLOEXEC|O_NONBLOCK);
|
||||
if (fd < 0)
|
||||
return (void) log_debug_errno(fd, "Failed to open terminal '%s', ignoring: %m", path);
|
||||
@@ -987,8 +986,8 @@ static bool exec_context_may_touch_tty(const ExecContext *ec) {
|
||||
ec->tty_vhangup ||
|
||||
ec->tty_vt_disallocate ||
|
||||
exec_input_is_terminal(ec->std_input) ||
|
||||
exec_output_is_terminal(ec->std_output) ||
|
||||
exec_output_is_terminal(ec->std_error);
|
||||
ec->std_output == EXEC_OUTPUT_TTY ||
|
||||
ec->std_error == EXEC_OUTPUT_TTY;
|
||||
}
|
||||
|
||||
bool exec_context_may_touch_console(const ExecContext *ec) {
|
||||
|
||||
@@ -478,6 +478,16 @@ static inline bool exec_output_is_kmsg(ExecOutput o) {
|
||||
EXEC_OUTPUT_KMSG_AND_CONSOLE);
|
||||
}
|
||||
|
||||
static inline bool exec_context_has_tty(const ExecContext *context) {
|
||||
assert(context);
|
||||
|
||||
return
|
||||
context->tty_path ||
|
||||
exec_input_is_terminal(context->std_input) ||
|
||||
context->std_output == EXEC_OUTPUT_TTY ||
|
||||
context->std_error == EXEC_OUTPUT_TTY;
|
||||
}
|
||||
|
||||
int exec_spawn(
|
||||
Unit *unit,
|
||||
ExecCommand *command,
|
||||
|
||||
Reference in New Issue
Block a user