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.
This commit is contained in:
parent
c331811c91
commit
371f3cb5ec
5
find.c
5
find.c
@ -235,6 +235,11 @@ spawn(char *argv[])
|
|||||||
pid_t pid;
|
pid_t pid;
|
||||||
int status;
|
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())) {
|
switch((pid = fork())) {
|
||||||
case -1:
|
case -1:
|
||||||
eprintf("fork:");
|
eprintf("fork:");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user