Re: Introduce posix_spawn

2018-09-23 Thread James Youngman
Something I haven't heard explained on this thread yet is why the change would be worthwhile in terms of cost (to e.g. the GNU project) vs. benefit (to e.g. users). The cost is, I hope, reasonably obvious: - the maintenance burden of the extra code and maintaining both fork/exec and posix_spawn i

Re: Introduce posix_spawn

2018-09-13 Thread Bernhard Voelker
On 9/7/18 7:24 AM, Barath Aron wrote: > Any thoughts on posix_spawn()? It seems to be possible now with the ...addfchdir() function for find/exec.c. In xargs, the error detection is a bit more detailed, so this might become a bit more complicated. In general, I think the code will have to be doub

Re: Introduce posix_spawn

2018-09-10 Thread Tavian Barnes
> Eric Blake wrote: > > Although it gets prohibitively expensive in a multi-threaded process to > > ensure proper locking between all threads that might want to use > > posix_spawn > > Why locking? posix_spawn uses fork() - the vfork() optimization is not > possible in the case when there are file

Re: Introduce posix_spawn

2018-09-10 Thread Eric Blake
On 09/08/2018 02:24 AM, Bernhard Voelker wrote: On 09/08/18 00:15, Eric Blake wrote: Adding posix_spawn_file_actions_addchdir() is what avoids the need to lock in the parent, because now you do: A thought WRT the naming: while ..._addopen() can be called for more file descriptors, there's only

Re: Introduce posix_spawn

2018-09-08 Thread Bernhard Voelker
On 09/08/18 00:15, Eric Blake wrote: > Adding posix_spawn_file_actions_addchdir() is what avoids the need to > lock in the parent, because now you do: A thought WRT the naming: while ..._addopen() can be called for more file descriptors, there's only one working directory for the spawned process.

Re: Introduce posix_spawn

2018-09-07 Thread Eric Blake
On 09/07/2018 05:06 PM, Bruno Haible wrote: Eric Blake wrote: Although it gets prohibitively expensive in a multi-threaded process to ensure proper locking between all threads that might want to use posix_spawn Why locking? posix_spawn uses fork() - the vfork() optimization is not possible in

Re: Introduce posix_spawn

2018-09-07 Thread Bruno Haible
Eric Blake wrote: > Although it gets prohibitively expensive in a multi-threaded process to > ensure proper locking between all threads that might want to use > posix_spawn Why locking? posix_spawn uses fork() - the vfork() optimization is not possible in the case when there are file actions -,

Re: Introduce posix_spawn

2018-09-07 Thread Eric Blake
On 09/07/2018 02:17 PM, Barath Aron wrote: In fact, it's so useful that I just proposed that POSIX standardize it, as well as fchdir: http://austingroupbugs.net/view.php?id=1208 Good to hear, I'm looking forward to this. It seems you have a typo in it: > int posix_spawn_file_actions_addch

Re: Introduce posix_spawn

2018-09-07 Thread Barath Aron
On 9/7/18 8:59 PM, Eric Blake wrote: On 09/07/2018 09:44 AM, Eric Blake wrote: Adding gnulib: On 09/06/2018 11:37 PM, Barath Aron wrote: On 9/7/18 4:54 AM, Dale R. Worley wrote: Couldn't you change the w.d. to the correct target, spawn, and then change the w.d. back? Yes, one could do thi

Re: Introduce posix_spawn

2018-09-07 Thread Eric Blake
On 09/07/2018 09:44 AM, Eric Blake wrote: Adding gnulib: On 09/06/2018 11:37 PM, Barath Aron wrote: On 9/7/18 4:54 AM, Dale R. Worley wrote: Couldn't you change the w.d. to the correct target, spawn, and then change the w.d. back? Yes, one could do this. Although it gets prohibitively expen

Re: Introduce posix_spawn

2018-09-07 Thread Eric Blake
Adding gnulib: On 09/06/2018 11:37 PM, Barath Aron wrote: On 9/7/18 4:54 AM, Dale R. Worley wrote: Couldn't you change the w.d. to the correct target, spawn, and then change the w.d. back? Yes, one could do this. Alternatively, one could direct the spawned process to run a program that would

Re: Introduce posix_spawn

2018-09-06 Thread Barath Aron
On 9/7/18 7:19 AM, Bernhard Voelker wrote: On 09/07/18 06:37, Barath Aron wrote: Alternatively, one could direct the spawned process to run a program that would set the working directory to, say, the first argument, and then use the remaining arguments to run/fork/spawn the target program. Do y

Re: Introduce posix_spawn

2018-09-06 Thread Bernhard Voelker
On 09/07/18 06:37, Barath Aron wrote: >> Alternatively, one could direct the spawned process to run a program >> that would set the working directory to, say, the first argument, and >> then use the remaining arguments to run/fork/spawn the target program. > > Do you know systems that have this pr

Re: Introduce posix_spawn

2018-09-06 Thread Barath Aron
On 9/7/18 4:54 AM, Dale R. Worley wrote: Couldn't you change the w.d. to the correct target, spawn, and then change the w.d. back? Yes, one could do this. Alternatively, one could direct the spawned process to run a program that would set the working directory to, say, the first argument, and t

Re: Introduce posix_spawn

2018-09-06 Thread Dale R. Worley
Tavian Barnes writes: > One thing you'll probably run into is that posix_spawn() has no interface > for running the spawned process in a new working directory. That makes > implementing -execdir/-okdir somewhat awkward. Couldn't you change the w.d. to the correct target, spawn, and then change t

RE: Introduce posix_spawn

2018-09-06 Thread Tavian Barnes
> Hello again, > > I intended to introduce the use of the posix_spawn to the findutils. The > Threos OS ( https://threos.io ), as you might know, does not support fork, > but it has posix_spawn. My plan is the following: I write the code that > implement the process spawning with the posix_spawn, a