summaryrefslogtreecommitdiffstats
path: root/exec.c
diff options
context:
space:
mode:
Diffstat (limited to 'exec.c')
-rw-r--r--exec.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/exec.c b/exec.c
index 310756b..4cfb2e0 100644
--- a/exec.c
+++ b/exec.c
@@ -325,6 +325,15 @@ static void bfs_exec_closewd(struct bfs_exec *execbuf, const struct BFTW *ftwbuf
/** Actually spawn the process. */
static int bfs_exec_spawn(const struct bfs_exec *execbuf) {
+ // Before executing anything, flush all open streams. This ensures that
+ // - the user sees everything relevant before an -ok[dir] prompt
+ // - output from commands is interleaved consistently with bfs
+ // - executed commands can rely on I/O from other bfs actions
+ //
+ // We do not check errors here, but they will be caught at cleanup time
+ // with ferror().
+ fflush(NULL);
+
if (execbuf->flags & BFS_EXEC_CONFIRM) {
for (size_t i = 0; i < execbuf->argc; ++i) {
fprintf(stderr, "%s ", execbuf->argv[i]);