From: Lennart Poettering Date: Wed, 21 Feb 2018 23:35:00 +0000 (+0100) Subject: tree-wide: reopen log when we need to log in FORK_CLOSE_ALL_FDS children X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=4809beb5fe6a0651b46a3663a9e12a65dd7f451d;p=elogind.git tree-wide: reopen log when we need to log in FORK_CLOSE_ALL_FDS children In a number of occasions we use FORK_CLOSE_ALL_FDS when forking off a child, since we don't want to pass fds to the processes spawned (either because we later want to execve() some other process there, or because our child might hang around for longer than expected, in which case it shouldn't keep our fd pinned). This also closes any logging fds, and thus means logging is turned off in the child. If we want to do proper logging, explicitly reopen the logs hence in the child at the right time. This is particularly crucial in the umount/remount children we fork off the shutdown binary, as otherwise the children can't log, which is why #8155 is harder to debug than necessary: the log messages we generate about failing mount() system calls aren't actually visible on screen, as they done in the child processes where the log fds are closed. --- diff --git a/src/login/inhibit.c b/src/login/inhibit.c index 7e6812c2d..1ef98daa2 100644 --- a/src/login/inhibit.c +++ b/src/login/inhibit.c @@ -276,6 +276,7 @@ int main(int argc, char *argv[]) { if (r == 0) { /* Child */ execvp(argv[optind], argv + optind); + log_open(); log_error_errno(errno, "Failed to execute %s: %m", argv[optind]); _exit(EXIT_FAILURE); }