diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-05-24 16:25:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-05-24 16:25:22 +0200 |
commit | 7cd92e2e9dcaed160558e7f955bebf8824a8c768 (patch) | |
tree | 5866974268e6810fabad1e9004f784bb02fde9af /src/nspawn | |
parent | 6e2d744b2f8ce8dac0bc686db217c4f45d3148d2 (diff) | |
parent | 17cac366ae5f31d07fc245bef702e6ec953e4cab (diff) | |
download | systemd-7cd92e2e9dcaed160558e7f955bebf8824a8c768.tar.gz |
Merge pull request #9068 from poettering/nspawn-pty-deadlock
nspawn logging deadlock fix
Diffstat (limited to 'src/nspawn')
-rw-r--r-- | src/nspawn/nspawn.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index a8b4c8224c..638935d551 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -2597,15 +2597,12 @@ static int inner_child( return r; } - /* Now, explicitly close the log, so that we - * then can close all remaining fds. Closing - * the log explicitly first has the benefit - * that the logging subsystem knows about it, - * and is thus ready to be reopened should we - * need it again. Note that the other fds - * closed here are at least the locking and - * barrier fds. */ + /* Now, explicitly close the log, so that we then can close all remaining fds. Closing the log explicitly first + * has the benefit that the logging subsystem knows about it, and is thus ready to be reopened should we need + * it again. Note that the other fds closed here are at least the locking and barrier fds. */ log_close(); + log_set_open_when_needed(true); + (void) fdset_close_others(fds); if (arg_start_mode == START_BOOT) { @@ -2643,9 +2640,7 @@ static int inner_child( exec_target = "/bin/bash, /bin/sh"; } - r = -errno; - (void) log_open(); - return log_error_errno(r, "execv(%s) failed: %m", exec_target); + return log_error_errno(errno, "execv(%s) failed: %m", exec_target); } static int setup_sd_notify_child(void) { @@ -2725,6 +2720,11 @@ static int outer_child( if (terminal < 0) return log_error_errno(terminal, "Failed to open console: %m"); + /* Make sure we can continue logging to the original stderr, even if stderr points elsewhere now */ + r = log_dup_console(); + if (r < 0) + return log_error_errno(r, "Failed to duplicate stderr: %m"); + r = rearrange_stdio(terminal, terminal, terminal); /* invalidates 'terminal' on success and failure */ if (r < 0) return log_error_errno(r, "Failed to move console to stdin/stdout/stderr: %m"); |