From a4f95ccad41f5befb6768ff58fe26b179237df6a Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 12 Jan 2015 19:42:29 -0500 Subject: [PATCH] e2fsck: close the progress_fd in the logfile child process If e2fsck.conf's logging feature is enabled, and e2fsck is being run via systemd-fsck, there will be a deadlock since systemd-fsck is waiting for progress_fd pipe to be closed, instead of waiting for the fsck process to exit --- and so the logfile child process won't exit until it can write out the logfile, and systemd won't continue the boot process so that the file system can be remounted read-write. Oops. Addresses-Debian-Bug: #775234 Signed-off-by: Theodore Ts'o --- e2fsck/logfile.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/e2fsck/logfile.c b/e2fsck/logfile.c index c48b8eb8..e004f31a 100644 --- a/e2fsck/logfile.c +++ b/e2fsck/logfile.c @@ -20,6 +20,8 @@ #include "e2fsck.h" #include +extern e2fsck_t e2fsck_global_ctx; /* Try your very best not to use this! */ + struct string { char *s; int len; @@ -233,6 +235,8 @@ static FILE *save_output(const char *s0, const char *s1, const char *s2) } if (pid == 0) { + if (e2fsck_global_ctx && e2fsck_global_ctx->progress_fd) + close(e2fsck_global_ctx->progress_fd); if (daemon(0, 0) < 0) { perror("daemon"); exit(1);