summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2008-07-22 07:12:46 (GMT)
committerJunio C Hamano <gitster@pobox.com>2008-07-26 04:29:44 (GMT)
commitccf08bc3d06050fbe9b76846f6e2ab6d1cd6bd09 (patch)
tree329272d9a8a8b220f0daa5764ad5cbde554d977e
parentb0320eaf6a25fbc4adf35d611c27006e6d853aa8 (diff)
downloadgit-ccf08bc3d06050fbe9b76846f6e2ab6d1cd6bd09.zip
git-ccf08bc3d06050fbe9b76846f6e2ab6d1cd6bd09.tar.gz
git-ccf08bc3d06050fbe9b76846f6e2ab6d1cd6bd09.tar.bz2
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>
-rw-r--r--run-command.c2
-rw-r--r--run-command.h1
2 files changed, 3 insertions, 0 deletions
diff --git a/run-command.c b/run-command.c
index 6e29fdf..73d0c31 100644
--- a/run-command.c
+++ b/run-command.c
@@ -110,6 +110,8 @@ int start_command(struct child_process *cmd)
unsetenv(*cmd->env);
}
}
+ if (cmd->preexec_cb)
+ cmd->preexec_cb();
if (cmd->git_cmd) {
execv_git_cmd(cmd->argv);
} else {
diff --git a/run-command.h b/run-command.h
index 5203a9e..4f2b7d7 100644
--- a/run-command.h
+++ b/run-command.h
@@ -42,6 +42,7 @@ struct child_process {
unsigned no_stderr:1;
unsigned git_cmd:1; /* if this is to be git sub-command */
unsigned stdout_to_stderr:1;
+ void (*preexec_cb)(void);
};
int start_command(struct child_process *);