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