3 ms·
In the case of execvp, you would pretty much be required to fork before it and then you could change PATH.
by anttihaapala 3y ago
In the case of execvp, you would pretty much be required to fork before it and then you could change PATH.
- oefrha 3y agoYeah, fork()+immediately exec() should be safe, but those use cases are almost always better with posix_spawn(), due to issues with fork(), like memory copying. And if you want to use the p-variant of posix_spawn you’re back to setting PATH beforehand. These APIs designed back in Stone Age just aren’t very well thought-out wrt concurrency and high performance.
- jstimpfle 3y agoWhy would you change the path just to call posix_spawnp()? If you want that control, that is an indication that you want to specify the path to the executable, not use PATH.