Skip to content

Commit

Permalink
Add output flushing before fork()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Anders Melchiorsen authored and Junio C Hamano committed Aug 5, 2008
1 parent 6119216 commit 7d0b18a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
13 changes: 6 additions & 7 deletions builtin-ls-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
1 change: 1 addition & 0 deletions run-command.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7d0b18a

Please sign in to comment.