nspawn: make sure our container PID 1 keeps logging to the original stderr as long as possible

If we log to the pty that is configured as stdin/stdout/stderr of the
container too early we risk filling it up in full before we start
processing the pty from the parent process, resulting in deadlocks.
Let's hence keep a copy of the original tty we were started on before
setting up stdin/stdout/stderr, so that we can log to it, and keep using
it as long as we can.

Since the kernel's pty internal buffer is pretty small this actually
triggered deadlocks when we debug logged at lot from nspawn's child
processes, see: https://github.com/systemd/systemd/pull/9024#issuecomment-390403674

With this change we won't use the pty at all, only the actual payload we
start will, and hence we won't deadlock on it, ever.
This commit is contained in:
Lennart Poettering
2018-05-22 16:52:50 +02:00
parent 8ca082b49a
commit 17cac366ae
3 changed files with 24 additions and 0 deletions
+2
View File
@@ -284,6 +284,8 @@ void log_set_open_when_needed(bool b);
* stderr, the console or kmsg */
void log_set_prohibit_ipc(bool b);
int log_dup_console(void);
int log_syntax_internal(
const char *unit,
int level,