Re:Setenv Is Not Thread Safe and C Doesn't Want to Fix It
by namibj on Monday November 20, 2023 @03:11PM
(#38353879)
There are OS specific APIs where needed, probably also for threads.
[ Parent
| on HN ]
Re:Setenv Is Not Thread Safe and C Doesn't Want to Fix It
by connicpu on Monday November 20, 2023 @04:13PM
(#38354876)
`std::os::unix does` adds some additional methods in that vein like exec(), but no fork(). `std::os::linux` only adds the ability to get `pidfd`s for child processes you create. There's simply no safe way for the stdlib to provide safe fork() without knowing a lot of things about how you're going to set up your process and what other libraries you might pull in that may not be fork-safe. If you're willing to ensure you only call it in a safe way, you can still call fork, the language just cannot guarantee it will be safe, same as when you're doing it in C.