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 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 program? What is the name of this utility program?
Indeed, I would expect Threos to have a system program to do exactly
this, since other people must have seen the same problem.

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)


Aron


[1] https://docs.oracle.com/cd/E86824_01/html/E54766/posix-spawn-file-actions-addchdir-np-3c.html




--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Reply via email to