Skip to content

Commit 4141831

Browse files
martinetdkdave
authored andcommitted
btrfs-progs: utils: flush stdout after prompt in ask_user()
When stdio is line buffered printf will not flush anything (on musl?), leaving the program hanging without displaying any prompt and weird dialogs such as the following: alpine:~# btrfstune -S 0 /dev/mmcblk1p1 WARNING: this is dangerous, clearing the seeding flag may cause the derived device not to be mountable! y WARNING: seeding flag is not set on /dev/mmcblk1p1 We are going to clear the seeding flag, are you sure? [y/N]: alpine:~# Forcing flush makes the prompt display properly. Signed-off-by: Dominique Martinet <[email protected]> Reviewed-by: Qu Wenruo <[email protected]>
1 parent b422f5c commit 4141831

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

common/utils.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ int ask_user(const char *question)
416416
char *answer;
417417

418418
printf("%s [y/N]: ", question);
419+
fflush(stdout);
419420

420421
return fgets(buf, sizeof(buf) - 1, stdin) &&
421422
(answer = strtok_r(buf, " \t\n\r", &saveptr)) &&

0 commit comments

Comments
 (0)