diff --git a/man/systemd-nspawn.xml b/man/systemd-nspawn.xml index 1e7e6a82d53..c8fbb01d007 100644 --- a/man/systemd-nspawn.xml +++ b/man/systemd-nspawn.xml @@ -1370,15 +1370,18 @@ Configures how to set up standard input, output and error output for the container payload, as well as the /dev/console device for the container. Takes one of - , , , or - . If , a pseudo-TTY is allocated and made available - as /dev/console in the container. It is then bi-directionally connected to the - standard input and output passed to systemd-nspawn. is - similar but only the output of the container is propagated and no input from the caller is read. If - , a pseudo TTY is allocated, but it is not connected anywhere. Finally, in - mode no pseudo TTY is allocated, but the standard input, output and error - output file descriptors passed to systemd-nspawn are passed on — as they are — to - the container payload, see the following paragraph. Defaults to if + , , , + or . If , a pseudo-TTY is + allocated and made available as /dev/console in the container. It is then + bi-directionally connected to the standard input and output passed to + systemd-nspawn. is similar but only the output of the + container is propagated and no input from the caller is read. If , a pseudo + TTY is allocated, but it is not connected anywhere. In mode no pseudo TTY is + allocated, but the standard input, output and error output file descriptors passed to + systemd-nspawn are passed on — as they are — to the container payload, see the + following paragraph. Finally, mode operates like + when systemd-nspawn is invoked on a terminal, and + like otherwise. Defaults to if systemd-nspawn is invoked from a terminal, and otherwise. diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 282f12d9c14..11a82090b09 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -256,10 +256,11 @@ STATIC_DESTRUCTOR_REGISTER(arg_sysctl, strv_freep); static int handle_arg_console(const char *arg) { if (streq(arg, "help")) { - puts("interactive\n" - "read-only\n" + puts("autopipe\n" + "interactive\n" "passive\n" - "pipe"); + "pipe\n" + "read-only"); return 0; } @@ -277,6 +278,11 @@ static int handle_arg_console(const char *arg) { "Proceeding anyway."); arg_console_mode = CONSOLE_PIPE; + } else if (streq(arg, "autopipe")) { + if (isatty(STDIN_FILENO) > 0 && isatty(STDOUT_FILENO) > 0) + arg_console_mode = CONSOLE_INTERACTIVE; + else + arg_console_mode = CONSOLE_PIPE; } else return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown console mode: %s", optarg);