diff options
| author | The8472 <git@infinite-source.de> | 2021-03-09 21:42:38 +0100 |
|---|---|---|
| committer | The8472 <git@infinite-source.de> | 2021-03-09 22:14:07 +0100 |
| commit | d854789ce191be25f2953c60fd50ce711776d9eb (patch) | |
| tree | b42897c0145876ef1cc7d82740a0b0a3dd8962dc /library/std/src/sys/unix/ext | |
| parent | 3a5d45f68cadc8fff4fbb557780f92b403b19c19 (diff) | |
| download | rust-d854789ce191be25f2953c60fd50ce711776d9eb.tar.gz rust-d854789ce191be25f2953c60fd50ce711776d9eb.zip | |
Do not attempt to unlock envlock in child process after a fork.
This is a breaking change for cases where the environment is accessed in a Command::pre_exec closure. Except for single-threaded programs these uses were not correct anyway since they aren't async-signal safe.
Diffstat (limited to 'library/std/src/sys/unix/ext')
| -rw-r--r-- | library/std/src/sys/unix/ext/process.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/library/std/src/sys/unix/ext/process.rs b/library/std/src/sys/unix/ext/process.rs index 88a27f27f66..d059ed44eed 100644 --- a/library/std/src/sys/unix/ext/process.rs +++ b/library/std/src/sys/unix/ext/process.rs @@ -62,9 +62,14 @@ pub trait CommandExt: Sealed { /// `fork`. This primarily means that any modifications made to memory on /// behalf of this closure will **not** be visible to the parent process. /// This is often a very constrained environment where normal operations - /// like `malloc` or acquiring a mutex are not guaranteed to work (due to + /// like `malloc`, accessing environment variables through [`std::env`] + /// or acquiring a mutex are not guaranteed to work (due to /// other threads perhaps still running when the `fork` was run). /// + /// For further details refer to the [POSIX fork() specification] + /// and the equivalent documentation for any targeted + /// platform, especially the requirements around *async-signal-safety*. + /// /// This also means that all resources such as file descriptors and /// memory-mapped regions got duplicated. It is your responsibility to make /// sure that the closure does not violate library invariants by making @@ -73,6 +78,10 @@ pub trait CommandExt: Sealed { /// When this closure is run, aspects such as the stdio file descriptors and /// working directory have successfully been changed, so output to these /// locations may not appear where intended. + /// + /// [POSIX fork() specification]: + /// https://pubs.opengroup.org/onlinepubs/9699919799/functions/fork.html + /// [`std::env`]: mod@crate::env #[stable(feature = "process_pre_exec", since = "1.34.0")] unsafe fn pre_exec<F>(&mut self, f: F) -> &mut process::Command where |
