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 this.

Although it gets prohibitively expensive in a multi-threaded process to ensure proper locking between all threads that might want to use posix_spawn, since fchdir() affects global process state.

Actually, this particular problem can be easily solved on Threos, because the posix_spawn() API offers a function for this: int posix_spawn_file_actions_addchdir_np(posix_spawn_file_actions_t* __restrict file_actions, const char* __restrict path);

Note the "np" at the end, it means "non portable". I also found references on Oracle's webpage [1].

It's useful enough that we may want to add support for this in gnulib, whether or not other systems pick up on it.  (gnulib is already able to overcome a lot of shortcomings in various platforms' posix_spawn)

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_addchdir(posix_spawn_file_actions_t *file_actions, int filedes);
Missing "f" in "addfchdir".


Reply via email to