Skip to content

Commit 5f91ad0

Browse files
committed
fuchsia: Fix default environment behavior when spawning
1 parent 7bfa2be commit 5f91ad0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/libstd/sys/unix/process/process_fuchsia.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ impl Command {
4848
use crate::sys::process::zircon::*;
4949

5050
let envp = match maybe_envp {
51-
Some(envp) => envp.as_ptr(),
51+
// None means to clone the current environment, which is done in the
52+
// flags below.
5253
None => ptr::null(),
54+
Some(envp) => envp.as_ptr(),
5355
};
5456

5557
let make_action = |local_io: &ChildStdio, target_fd| -> io::Result<fdio_spawn_action_t> {
@@ -104,7 +106,8 @@ impl Command {
104106
let mut process_handle: zx_handle_t = 0;
105107
zx_cvt(fdio_spawn_etc(
106108
ZX_HANDLE_INVALID,
107-
FDIO_SPAWN_CLONE_JOB | FDIO_SPAWN_CLONE_LDSVC | FDIO_SPAWN_CLONE_NAMESPACE,
109+
FDIO_SPAWN_CLONE_JOB | FDIO_SPAWN_CLONE_LDSVC | FDIO_SPAWN_CLONE_NAMESPACE
110+
| FDIO_SPAWN_CLONE_ENVIRON, // this is ignored when envp is non-null
108111
self.get_argv()[0], self.get_argv().as_ptr(), envp,
109112
actions.len() as size_t, actions.as_ptr(),
110113
&mut process_handle,

0 commit comments

Comments
 (0)