git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Flush output in start_async

From
AMAnders Melchiorsen <mail@cup.kalibalik.dk>
Date
Aug 4, 2008, 00:30 UTC
Message-ID
<1217809803-23391-1-git-send-email-mail@cup.kalibalik.dk>
In-Reply-To
<7vej557hlq.fsf@gitster.siamese.dyndns.org>
This prevents double output in case stdout is redirected.
Signed-off-by: Anders Melchiorsen <mail@cup.kalibalik.dk>
---
 run-command.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/run-command.c b/run-command.c
index a3b28a6..6af83c5 100644
--- a/run-command.c
+++ b/run-command.c
@@ -304,6 +304,9 @@ int start_async(struct async *async)
 	async->out = pipe_out[0];
 
 #ifndef __MINGW32__
+	/* Flush stdio before fork() to avoid cloning buffers */
+	fflush(NULL);
+
 	async->pid = fork();
 	if (async->pid < 0) {
 		error("fork (async) failed: %s", strerror(errno));
-- 
1.5.6.4
Previous: Junio C HamanoNext: Linus Torvalds
Message 6 of 8 in “Use line buffering for standard output”
  1. Use line buffering for standard outputAnders Melchiorsen, Aug 3, 2008
  2. Junio C HamanoAug 3, 2008
  3. Linus TorvaldsAug 3, 2008
  4. Anders MelchiorsenAug 3, 2008
  5. Junio C HamanoAug 4, 2008
  6. Flush output in start_asyncAnders Melchiorsen, Aug 4, 2008
  7. Linus TorvaldsAug 4, 2008
  8. Add output flushing before fork()Anders Melchiorsen, Aug 4, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.