diff options
| author | Eric Huss <eric@huss.org> | 2021-02-23 20:19:15 -0800 |
|---|---|---|
| committer | Eric Huss <eric@huss.org> | 2021-02-23 20:19:15 -0800 |
| commit | 476c6c27e751ced05f5c279770ff8f6a114fe8eb (patch) | |
| tree | 6eb168746fb40b3c37254999761a3b4e1af07e0f | |
| parent | fe1bf8e05c39bdcc73fc09e246b7209444e389bc (diff) | |
| download | rust-476c6c27e751ced05f5c279770ff8f6a114fe8eb.tar.gz rust-476c6c27e751ced05f5c279770ff8f6a114fe8eb.zip | |
Update outdated comment in unix Command.
| -rw-r--r-- | library/std/src/sys/unix/ext/process.rs | 2 | ||||
| -rw-r--r-- | library/std/src/sys/unix/process/process_common.rs | 22 |
2 files changed, 7 insertions, 17 deletions
diff --git a/library/std/src/sys/unix/ext/process.rs b/library/std/src/sys/unix/ext/process.rs index 7559c1f1d9e..88a27f27f66 100644 --- a/library/std/src/sys/unix/ext/process.rs +++ b/library/std/src/sys/unix/ext/process.rs @@ -172,6 +172,8 @@ impl CommandExt for process::Command { } fn exec(&mut self) -> io::Error { + // NOTE: This may *not* be safe to call after `libc::fork`, because it + // may allocate. That may be worth fixing at some point in the future. self.as_inner_mut().exec(sys::process::Stdio::Inherit) } diff --git a/library/std/src/sys/unix/process/process_common.rs b/library/std/src/sys/unix/process/process_common.rs index a96d4aa6a45..b9dcc4e4b9e 100644 --- a/library/std/src/sys/unix/process/process_common.rs +++ b/library/std/src/sys/unix/process/process_common.rs @@ -60,25 +60,13 @@ cfg_if::cfg_if! { //////////////////////////////////////////////////////////////////////////////// pub struct Command { - // Currently we try hard to ensure that the call to `.exec()` doesn't - // actually allocate any memory. While many platforms try to ensure that - // memory allocation works after a fork in a multithreaded process, it's - // been observed to be buggy and somewhat unreliable, so we do our best to - // just not do it at all! - // - // Along those lines, the `argv` and `envp` raw pointers here are exactly - // what's gonna get passed to `execvp`. The `argv` array starts with the - // `program` and ends with a NULL, and the `envp` pointer, if present, is - // also null-terminated. - // - // Right now we don't support removing arguments, so there's no much fancy - // support there, but we support adding and removing environment variables, - // so a side table is used to track where in the `envp` array each key is - // located. Whenever we add a key we update it in place if it's already - // present, and whenever we remove a key we update the locations of all - // other keys. program: CString, args: Vec<CString>, + /// Exactly what will be passed to `execvp`. + /// + /// First element is a pointer to `program`, followed by pointers to + /// `args`, followed by a `null`. Be careful when modifying `program` or + /// `args` to properly update this as well. argv: Argv, env: CommandEnv, |
