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.
Michael Forney 2021-09-10 22:45:30 -07:00
parent c331811c91
commit 371f3cb5ec
1 changed files with 5 additions and 0 deletions

View File

@ -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. */
switch((pid = fork())) {
case -1: