<listitem><para>Configures how to set up standard input, output and error output for the container
payload, as well as the <filename>/dev/console</filename> device for the container. Takes one of
- <option>interactive</option>, <option>read-only</option>, <option>passive</option>, or
- <option>pipe</option>. If <option>interactive</option>, a pseudo-TTY is allocated and made available
- as <filename>/dev/console</filename> in the container. It is then bi-directionally connected to the
- standard input and output passed to <command>systemd-nspawn</command>. <option>read-only</option> is
- similar but only the output of the container is propagated and no input from the caller is read. If
- <option>passive</option>, a pseudo TTY is allocated, but it is not connected anywhere. Finally, in
- <option>pipe</option> mode no pseudo TTY is allocated, but the standard input, output and error
- output file descriptors passed to <command>systemd-nspawn</command> are passed on — as they are — to
- the container payload, see the following paragraph. Defaults to <option>interactive</option> if
+ <option>interactive</option>, <option>read-only</option>, <option>passive</option>,
+ <option>pipe</option> or <option>autopipe</option>. If <option>interactive</option>, a pseudo-TTY is
+ allocated and made available as <filename>/dev/console</filename> in the container. It is then
+ bi-directionally connected to the standard input and output passed to
+ <command>systemd-nspawn</command>. <option>read-only</option> is similar but only the output of the
+ container is propagated and no input from the caller is read. If <option>passive</option>, a pseudo
+ TTY is allocated, but it is not connected anywhere. In <option>pipe</option> mode no pseudo TTY is
+ allocated, but the standard input, output and error output file descriptors passed to
+ <command>systemd-nspawn</command> are passed on — as they are — to the container payload, see the
+ following paragraph. Finally, <option>autopipe</option> mode operates like
+ <option>interactive</option> when <command>systemd-nspawn</command> is invoked on a terminal, and
+ like <option>pipe</option> otherwise. Defaults to <option>interactive</option> if
<command>systemd-nspawn</command> is invoked from a terminal, and <option>read-only</option>
otherwise.</para>
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;
}
"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);