find: Flush stdout before executing commands

The commands may produce output themselves, so this is required to
ensure that our -print output is actually written before a command's
output, and also that we don't end up with partially written lines
due to stdout buffering intermixed with the output of other commands.

Other implementations of find(1) do the same.
master
Michael Forney 1 year ago
parent c331811c91
commit 371f3cb5ec

@ -235,6 +235,11 @@ spawn(char *argv[])
pid_t pid;
int status;
/* flush stdout so that -print output always appears before
* any output from the command and does not get cut-off in
* the middle of a line. */
fflush(stdout);
switch((pid = fork())) {
case -1:
eprintf("fork:");

Loading…
Cancel
Save