Introduction
Introduction Statistics Contact Development Disclaimer Help
find: Flush stdout before executing commands - sbase - suckless unix tools
git clone git://git.suckless.org/sbase
Log
Files
Refs
README
LICENSE
---
commit 371f3cb5ec3b8ef3135b3729326bfd6c7b7cb85c
parent c331811c91d9141a1b6c5273115517185d39df60
Author: Michael Forney <[email protected]>
Date: Fri, 10 Sep 2021 22:45:30 -0700
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.
Diffstat:
M find.c | 5 +++++
1 file changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/find.c b/find.c
@@ -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:");
You are viewing proxied material from suckless.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.