Skip to content

Commit

Permalink
Clarify interface mismatch.
Browse files Browse the repository at this point in the history
  • Loading branch information
kosayoda committed Apr 24, 2024
1 parent ce6aeb3 commit 1314185
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/spawn.rs
Expand Up @@ -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<S: AsRef<CStr>>(args: &[S]) -> Vec<*mut libc::c_char> {
let mut v: Vec<*mut libc::c_char> = args
.iter()
Expand Down

0 comments on commit 1314185

Please sign in to comment.