(double) cur / (double) max;
}
-static int process_progress(int fd) {
- _cleanup_fclose_ FILE *console = NULL, *f = NULL;
+static int process_progress(int fd, FILE* console) {
+ _cleanup_fclose_ FILE *f = NULL;
usec_t last = 0;
bool locked = false;
int clear = 0, r;
return log_debug_errno(errno, "Failed to use pipe: %m");
}
- console = fopen("/dev/console", "we");
- if (!console)
- return log_debug_errno(errno, "Failed to open /dev/console, can't print progress output: %m");
-
for (;;) {
int pass, m;
unsigned long cur, max;
_cleanup_close_pair_ int progress_pipe[2] = { -1, -1 };
_cleanup_(sd_device_unrefp) sd_device *dev = NULL;
_cleanup_free_ char *dpath = NULL;
+ _cleanup_fclose_ FILE *console = NULL;
const char *device, *type;
bool root_directory;
struct stat st;
}
}
- if (arg_show_progress &&
+ console = fopen("/dev/console", "we");
+ if (console &&
+ arg_show_progress &&
pipe(progress_pipe) < 0)
return log_error_errno(errno, "pipe(): %m");
_exit(FSCK_OPERATIONAL_ERROR);
}
- progress_pipe[1] = safe_close(progress_pipe[1]);
- (void) process_progress(TAKE_FD(progress_pipe[0]));
+ if (console) {
+ progress_pipe[1] = safe_close(progress_pipe[1]);
+ (void) process_progress(TAKE_FD(progress_pipe[0]), console);
+ }
exit_status = wait_for_terminate_and_check("fsck", pid, WAIT_LOG_ABNORMAL);
if (exit_status < 0)