Re: [PATCH v6 04/11] run-command: use the async-signal-safe execv instead of execvp

2017-05-17 Thread Brandon Williams
On 05/16, Jeff King wrote: > On Wed, May 17, 2017 at 11:15:43AM +0900, Junio C Hamano wrote: > > > > + if (errno == ENOEXEC) > > > + execv(argv.argv[0], (char *const *) argv.argv); > > > > "/bin/sh" tries to run "/usr/bin/git" that was not executable (well, > > the one in

Re: [PATCH v6 04/11] run-command: use the async-signal-safe execv instead of execvp

2017-05-16 Thread Junio C Hamano
Jeff King writes: > This is about finding "/usr/bin/foo", realizing it cannot be exec'd > because it lacks a shebang line, and then pretending that it did have > "#!/bin/sh". IOW, maintaining compatibility with execvp(). > > So the command itself isn't a shell command, but it may execute a shell

Re: [PATCH v6 04/11] run-command: use the async-signal-safe execv instead of execvp

2017-05-16 Thread Jeff King
On Tue, May 16, 2017 at 10:26:02PM -0400, Jeff King wrote: > On Wed, May 17, 2017 at 11:15:43AM +0900, Junio C Hamano wrote: > > > > + if (errno == ENOEXEC) > > > + execv(argv.argv[0], (char *const *) argv.argv); > > > > "/bin/sh" tries to run "/usr/bin/git" that was not

Re: [PATCH v6 04/11] run-command: use the async-signal-safe execv instead of execvp

2017-05-16 Thread Jeff King
On Wed, May 17, 2017 at 11:15:43AM +0900, Junio C Hamano wrote: > > + if (errno == ENOEXEC) > > + execv(argv.argv[0], (char *const *) argv.argv); > > "/bin/sh" tries to run "/usr/bin/git" that was not executable (well, > the one in "usr/bin/" would have +x bit, but let

Re: [PATCH v6 04/11] run-command: use the async-signal-safe execv instead of execvp

2017-05-16 Thread Junio C Hamano
Brandon Williams writes: > @@ -238,6 +238,12 @@ static void prepare_cmd(struct argv_array *out, const > struct child_process *cmd) > if (!cmd->argv[0]) > die("BUG: command is empty"); > > + /* > + * Add SHELL_PATH so in the event exec fails with ENOEXEC we can > +

[PATCH v6 04/11] run-command: use the async-signal-safe execv instead of execvp

2017-04-19 Thread Brandon Williams
Convert the function used to exec from 'execvp()' to 'execv()' as the (p) variant of exec isn't async-signal-safe and has the potential to call malloc during the path resolution it performs. Instead we simply do the path resolution ourselves during the preparation stage prior to forking. There al