diff options
| author | Junio C Hamano <gitster@pobox.com> | 2014-10-24 14:57:53 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2014-10-24 14:57:54 -0700 |
| commit | 217610d7d61864f24efc0ea837dc911be44fd9c6 (patch) | |
| tree | ebcbe1cde6d22498c7007a0b3e117e93168378f8 /run-command.c | |
| parent | f35a02b15d22521c4902d8b3434c7c55eeab4a1d (diff) | |
| parent | a915459097b72da9cc058172a54029352b684b0f (diff) | |
| download | git-217610d7d61864f24efc0ea837dc911be44fd9c6.tar.xz | |
Merge branch 'rs/run-command-env-array'
Add managed "env" array to child_process to clarify the lifetime
rules.
* rs/run-command-env-array:
use env_array member of struct child_process
run-command: add env_array, an optional argv_array for env
Diffstat (limited to 'run-command.c')
| -rw-r--r-- | run-command.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/run-command.c b/run-command.c index 761f0fde40..46be513c48 100644 --- a/run-command.c +++ b/run-command.c @@ -12,6 +12,7 @@ void child_process_init(struct child_process *child) { memset(child, 0, sizeof(*child)); argv_array_init(&child->args); + argv_array_init(&child->env_array); } struct child_to_clean { @@ -287,6 +288,8 @@ int start_command(struct child_process *cmd) if (!cmd->argv) cmd->argv = cmd->args.argv; + if (!cmd->env) + cmd->env = cmd->env_array.argv; /* * In case of errors we must keep the promise to close FDs @@ -338,6 +341,7 @@ fail_pipe: error("cannot create %s pipe for %s: %s", str, cmd->argv[0], strerror(failed_errno)); argv_array_clear(&cmd->args); + argv_array_clear(&cmd->env_array); errno = failed_errno; return -1; } @@ -524,6 +528,7 @@ fail_pipe: else if (cmd->err) close(cmd->err); argv_array_clear(&cmd->args); + argv_array_clear(&cmd->env_array); errno = failed_errno; return -1; } @@ -550,6 +555,7 @@ int finish_command(struct child_process *cmd) { int ret = wait_or_whine(cmd->pid, cmd->argv[0]); argv_array_clear(&cmd->args); + argv_array_clear(&cmd->env_array); return ret; } |
