Re: [PATCH 5/5] run-command: add note about forking and threading

2017-04-11 Thread Eric Wong
Brandon Williams wrote: > On 04/11, Eric Wong wrote: > > On the other hand, I believe we should make run-command > > vfork-compatible (and Brandon's series is a big (but incomplete) > > step in the (IMHO) right direction); as anything which is > > vfork-safe would also be safe in the presence of t

Re: [PATCH 5/5] run-command: add note about forking and threading

2017-04-11 Thread Brandon Williams
On 04/11, Eric Wong wrote: > Jonathan Nieder wrote: > > Why can't git use e.g. posix_spawn to avoid this? > > posix_spawn does not support chdir, and it seems we run non-git > commands so no using "git -C" for those. This is actually the biggest reason why I didn't go down that route from the st

Re: [PATCH 5/5] run-command: add note about forking and threading

2017-04-11 Thread Jonathan Nieder
Eric Wong wrote: > Jonathan Nieder wrote: >> Why can't git use e.g. posix_spawn to avoid this? > > posix_spawn does not support chdir, and it seems we run non-git > commands so no using "git -C" for those. On the other hand, a number of the non-git commands we run are in a shell. At the cost of

Re: [PATCH 5/5] run-command: add note about forking and threading

2017-04-10 Thread Eric Wong
Jonathan Nieder wrote: > Hi, > > Brandon Williams wrote: > > > --- a/run-command.c > > +++ b/run-command.c > > @@ -458,6 +458,14 @@ int start_command(struct child_process *cmd) > > argv_array_pushv(&argv, cmd->argv); > > } > > > > + /* > > +* NOTE: In order to prevent dea

Re: [PATCH 5/5] run-command: add note about forking and threading

2017-04-10 Thread Jonathan Nieder
Hi, Brandon Williams wrote: > --- a/run-command.c > +++ b/run-command.c > @@ -458,6 +458,14 @@ int start_command(struct child_process *cmd) > argv_array_pushv(&argv, cmd->argv); > } > > + /* > + * NOTE: In order to prevent deadlocking when using threads special > +

[PATCH 5/5] run-command: add note about forking and threading

2017-04-10 Thread Brandon Williams
Allocation was pushed before forking in order to avoid potential deadlocking when forking while multiple threads are running. This deadlocking is possible when a thread (other than the one forking) has acquired a lock and didn't get around to releasing it before the fork. This leaves the lock in a