Skip to content

Commit

Permalink
run-command: add pre-exec callback
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Jul 26, 2008
1 parent b0320ea commit ccf08bc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions run-command.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions run-command.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down

0 comments on commit ccf08bc

Please sign in to comment.