3 ms·
Once again, the OP asked why setenv is even needed, which implies they likely don’t have much experience with spawning processes in low level languages, so I us
by oefrha 3y ago
Once again, the OP asked why setenv is even needed, which implies they likely don’t have much experience with spawning processes in low level languages, so I used the more familiar shell script setting as an illustrative example, as setenv is analogous to export in POSIX sh. I never said export is implemented with setenv, or shell script exports aren’t thread safe. Unfortunately, replies hung up on shell scripts.
As for I’m not aware of execve etc… You need to re-read my comment which clearly mentions execve, execvep, posix_spawn, as well as implementing PATH search on your own.
- eqvinox 3y ago> Once again, the OP asked why setenv is even needed, which implies they likely don’t have much experience with spawning processes in low level languages I am the OP and your assumption is incorrect. You may consider why the post ends with: (NB: starting a new process is not "at runtime")
- Izkata 3y ago"export" in shells has to change the environ before they start the new process. It may not be "at runtime" for the new process, but it would be for the shell.
- account42 3y agoWrong, export does not have to change the shell's environment at all. There are plenty of exec variants that accept a different environment pointer, same for posix_spawn.