Add output flushing before fork()

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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Anders Melchiorsen 2008-08-04 12:18:40 +02:00 committed by Junio C Hamano
parent 611921654f
commit 7d0b18a4da
2 changed files with 7 additions and 7 deletions

View file

@ -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? * Maybe we want to have some recursive version here?
* *
* Something like: * Something similar to this incomplete example:
* *
if (show_subprojects(base, baselen, pathname)) { if (show_subprojects(base, baselen, pathname)) {
if (fork()) { struct child_process ls_tree;
chdir(base);
exec ls-tree; ls_tree.dir = base;
} ls_tree.argv = ls-tree;
waitpid(); start_command(&ls_tree);
} }
* *
* ..or similar..
*/ */
type = commit_type; type = commit_type;
} else if (S_ISDIR(mode)) { } else if (S_ISDIR(mode)) {

View file

@ -68,6 +68,7 @@ int start_command(struct child_process *cmd)
trace_argv_printf(cmd->argv, "trace: run_command:"); trace_argv_printf(cmd->argv, "trace: run_command:");
#ifndef __MINGW32__ #ifndef __MINGW32__
fflush(NULL);
cmd->pid = fork(); cmd->pid = fork();
if (!cmd->pid) { if (!cmd->pid) {
if (cmd->no_stdin) if (cmd->no_stdin)