diff --git a/src/spawn.rs b/src/spawn.rs index 782b6ef723..63d1519979 100644 --- a/src/spawn.rs +++ b/src/spawn.rs @@ -342,8 +342,13 @@ impl Drop for PosixSpawnFileActions { } } -// Specifically for use with posix_spawn and posix_spawnp. -// https://github.com/rust-lang/libc/issues/1272 +// The POSIX standard requires those `args` and `envp` to be of type `*const *mut [c_char]`, +// but implementations won't modify them, making the `mut` type redundant. Considering this, +// Nix does not expose this mutability, but we have to change the interface when calling the +// underlying libc interfaces , this helper function does the conversion job. +// +// SAFETY: +// It is safe to add the mutability in types as implementations won't mutable them. unsafe fn to_exec_array>(args: &[S]) -> Vec<*mut libc::c_char> { let mut v: Vec<*mut libc::c_char> = args .iter()