run-command: add pre-exec callback
This is a function provided by the caller which is called _after_ the process is forked, but before the spawned program is executed. On platforms (like mingw) where subprocesses are forked and executed in a single call, the preexec callback is simply ignored. This will be used in the following patch to do some setup for 'less' that must happen in the forked child. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jul 22, 2008 at 03:12 UTC
ccf08bc3d06050fbe9b76846f6e2ab6d1cd6bd09
2 files changed
+3
run-command.c
+2
@@ -110,6 +110,8 @@ int start_command(struct child_process *cmd)
110
unsetenv(*cmd->env);
111
}
112
}
113
+ if (cmd->preexec_cb)
114
+ cmd->preexec_cb();
115
if (cmd->git_cmd) {
116
execv_git_cmd(cmd->argv);
117
} else {
run-command.h
+1
@@ -42,6 +42,7 @@ struct child_process {
42
unsigned no_stderr:1;
43
unsigned git_cmd:1; /* if this is to be git sub-command */
44
unsigned stdout_to_stderr:1;
45
+ void (*preexec_cb)(void);
46
};
47
48
int start_command(struct child_process *);