@matheusbsbs / matheus-bagliano / commits / 7d0b18a4da
Fork 0

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>

Anders Melchiorsen committed Aug 4, 2008 at 12:18 UTC 7d0b18a4da1be9e738293cc13812757ca47ed109
2 files changed +7 -7
builtin-ls-tree.c
+6 -7
@@ -66,17 +66,16 @@ static int show_tree(const unsigned char *sha1, const char *base, int baselen,
66 /*
67 * Maybe we want to have some recursive version here?
68 *
69 - * Something like:
69 + * Something similar to this incomplete example:
70 *
71 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);
77 }
78 *
79 - * ..or similar..
79 */
80 type = commit_type;
81 } else if (S_ISDIR(mode)) {
run-command.c
+1
@@ -68,6 +68,7 @@ int start_command(struct child_process *cmd)
68 trace_argv_printf(cmd->argv, "trace: run_command:");
69
70 #ifndef __MINGW32__
71 + fflush(NULL);
72 cmd->pid = fork();
73 if (!cmd->pid) {
74 if (cmd->no_stdin)