git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anders Melchiorsen <mail@cup.kalibalik.dk>
To: gitster@pobox.com
Cc: git@vger.kernel.org, Anders Melchiorsen <mail@cup.kalibalik.dk>
Subject: [PATCH] Add output flushing before fork()
Date: Mon,  4 Aug 2008 12:18:40 +0200	[thread overview]
Message-ID: <1217845120-28134-1-git-send-email-mail@cup.kalibalik.dk> (raw)
In-Reply-To: <alpine.LFD.1.10.0808032241260.3668@nehalem.linux-foundation.org>

This adds fflush(NULL) before fork() in start_command(), to keep
the generic interface safe.

A remaining use of fork() with no flushing is in a comment in
show_tree(). Rewrite that comment to use start_command().

Signed-off-by: Anders Melchiorsen <mail@cup.kalibalik.dk>
---

This fixes up the remaining two spots that Linus suggested.


 builtin-ls-tree.c |   13 ++++++-------
 run-command.c     |    1 +
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/builtin-ls-tree.c b/builtin-ls-tree.c
index d25767a..cb61717 100644
--- a/builtin-ls-tree.c
+++ b/builtin-ls-tree.c
@@ -66,17 +66,16 @@ static int show_tree(const unsigned char *sha1, const char *base, int baselen,
 		/*
 		 * Maybe we want to have some recursive version here?
 		 *
-		 * Something like:
+		 * Something similar to this incomplete example:
 		 *
 		if (show_subprojects(base, baselen, pathname)) {
-			if (fork()) {
-				chdir(base);
-				exec ls-tree;
-			}
-			waitpid();
+			struct child_process ls_tree;
+
+			ls_tree.dir = base;
+			ls_tree.argv = ls-tree;
+			start_command(&ls_tree);
 		}
 		 *
-		 * ..or similar..
 		 */
 		type = commit_type;
 	} else if (S_ISDIR(mode)) {
diff --git a/run-command.c b/run-command.c
index 6af83c5..bbb9c77 100644
--- a/run-command.c
+++ b/run-command.c
@@ -68,6 +68,7 @@ int start_command(struct child_process *cmd)
 	trace_argv_printf(cmd->argv, "trace: run_command:");
 
 #ifndef __MINGW32__
+	fflush(NULL);
 	cmd->pid = fork();
 	if (!cmd->pid) {
 		if (cmd->no_stdin)
-- 
1.5.6.4

      reply	other threads:[~2008-08-04 10:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-03 21:26 [PATCH] Use line buffering for standard output Anders Melchiorsen
2008-08-03 21:38 ` Junio C Hamano
2008-08-03 21:46 ` Linus Torvalds
2008-08-03 22:48   ` Anders Melchiorsen
2008-08-04  0:24     ` Junio C Hamano
2008-08-04  0:30       ` [PATCH] Flush output in start_async Anders Melchiorsen
2008-08-04  5:50       ` [PATCH] Use line buffering for standard output Linus Torvalds
2008-08-04 10:18         ` Anders Melchiorsen [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1217845120-28134-1-git-send-email-mail@cup.kalibalik.dk \
    --to=mail@cup.kalibalik.dk \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).