Re:Don't setenv in multi-threaded code on glibc
by amluto on Tuesday January 31, 2017 @12:02PM
(#13532512)
That's an unfortunate implementation. posix_spawn() is much faster in large applications because it doesn't need to make all MAP_PRIVATE mappings read-only for CoW purposes.
Rust could hand-roll it by calling clone() directly, but the code is a bit tricky.
https://github.com/rust-lang/rust/blob/0c85f2a1bdb01666e74cd...
Command::spawn() calls fork(). And you can schedule things to run on the child with CommandExt::before_exec().