Whamcloud - gitweb
e2fsck: close the progress_fd in the logfile child process
authorTheodore Ts'o <tytso@mit.edu>
Tue, 13 Jan 2015 00:42:29 +0000 (19:42 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 13 Jan 2015 00:42:29 +0000 (19:42 -0500)
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 <tytso@mit.edu>
e2fsck/logfile.c

index c48b8eb..e004f31 100644 (file)
@@ -20,6 +20,8 @@
 #include "e2fsck.h"
 #include <pwd.h>
 
+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);