about summary refs log tree commit diff
path: root/cache.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cache.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/cache.c b/cache.c
index 55199e8..578b73b 100644
--- a/cache.c
+++ b/cache.c
@@ -265,6 +265,13 @@ static int process_slot(struct cache_slot *slot)
 {
 	int err;
 
+	/*
+	 * Make sure any buffered data is flushed before we redirect,
+	 * do sendfile(2) or write(2)
+	 */
+	if (fflush(stdout))
+		return errno;
+
 	err = open_slot(slot);
 	if (!err && slot->match) {
 		if (is_expired(slot)) {