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 <tytso@mit.edu>
test-maint
Theodore Ts'o 2015-01-12 19:42:29 -05:00
parent 13f450addb
commit a4f95ccad4
1 changed files with 4 additions and 0 deletions

View 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);