Skip to content

Commit ed94e99

Browse files
committed
Clarify interface mismatch.
1 parent b540af8 commit ed94e99

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/spawn.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,13 @@ impl Drop for PosixSpawnFileActions {
326326
}
327327
}
328328

329-
// Specifically for use with posix_spawn and posix_spawnp.
330-
// https://github.com/rust-lang/libc/issues/1272
329+
// The POSIX standard requires those `args` and `envp` to be of type `*const *mut [c_char]`,
330+
// but implementations won't modify them, making the `mut` type redundant. Considering this,
331+
// Nix does not expose this mutability, but we have to change the interface when calling the
332+
// underlying libc interfaces , this helper function does the conversion job.
333+
//
334+
// SAFETY:
335+
// It is safe to add the mutability in types as implementations won't mutable them.
331336
unsafe fn to_exec_array<S: AsRef<CStr>>(args: &[S]) -> Vec<*mut libc::c_char> {
332337
let mut v: Vec<*mut libc::c_char> = args
333338
.iter()

0 commit comments

Comments
 (0)