Skip to content

Commit 7d0b18a

Browse files
Anders Melchiorsengitster
authored andcommitted
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>
1 parent 6119216 commit 7d0b18a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

builtin-ls-tree.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,16 @@ static int show_tree(const unsigned char *sha1, const char *base, int baselen,
6666
/*
6767
* Maybe we want to have some recursive version here?
6868
*
69-
* Something like:
69+
* Something similar to this incomplete example:
7070
*
7171
if (show_subprojects(base, baselen, pathname)) {
72-
if (fork()) {
73-
chdir(base);
74-
exec ls-tree;
75-
}
76-
waitpid();
72+
struct child_process ls_tree;
73+
74+
ls_tree.dir = base;
75+
ls_tree.argv = ls-tree;
76+
start_command(&ls_tree);
7777
}
7878
*
79-
* ..or similar..
8079
*/
8180
type = commit_type;
8281
} else if (S_ISDIR(mode)) {

run-command.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ int start_command(struct child_process *cmd)
6868
trace_argv_printf(cmd->argv, "trace: run_command:");
6969

7070
#ifndef __MINGW32__
71+
fflush(NULL);
7172
cmd->pid = fork();
7273
if (!cmd->pid) {
7374
if (cmd->no_stdin)

0 commit comments

Comments
 (0)