From: Lennart Poettering Date: Tue, 22 May 2018 14:51:28 +0000 (+0200) Subject: nspawn: make use of log_set_open_when_needed() in nspawn too X-Git-Tag: v239~214^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8ca082b49ac816457dc258c297a96b2f623b152e;p=thirdparty%2Fsystemd.git nspawn: make use of log_set_open_when_needed() in nspawn too Let's make use of log_set_open_when_needed() in nspawn too, i.e. at the point where we close logging because we are about to rearrange fds, let's automatically reopen the logging fds when we need them, the same way as we do that in the service manager. This makes things simpler and more robust. --- diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 9cfbb1171e6..b1add0f1590 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) {