Skip to content

Commit ccf08bc

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b0320ea commit ccf08bc

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

run-command.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ int start_command(struct child_process *cmd)
110110
unsetenv(*cmd->env);
111111
}
112112
}
113+
if (cmd->preexec_cb)
114+
cmd->preexec_cb();
113115
if (cmd->git_cmd) {
114116
execv_git_cmd(cmd->argv);
115117
} else {

run-command.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct child_process {
4242
unsigned no_stderr:1;
4343
unsigned git_cmd:1; /* if this is to be git sub-command */
4444
unsigned stdout_to_stderr:1;
45+
void (*preexec_cb)(void);
4546
};
4647

4748
int start_command(struct child_process *);

0 commit comments

Comments
 (0)