upvote
Rust can't magically fix how Unix works. On Windows, the unsafe APIs in std::env are merely unsafe, if you use them carefully you're fine. On Unix, these APIs can cause chaos if you use them in multi-threaded context because Unix never provided any mechanism, even in a modern Linux, to do better.

Rust is doing everything it can here, these APIs are labelled unsafe, and on a system where they can work, they will work. You can see similar in the filesystem code. On Windows, or a modern Linux, you get what you'd like to have, and on somebody's SysV clone where that's not possible it's still not possible from Rust.

reply