about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTyler Mandry <tmandry@gmail.com>2019-08-30 18:52:19 -0700
committerTyler Mandry <tmandry@gmail.com>2019-08-30 18:52:26 -0700
commit5f91ad0e3300c36033bf409ceefb00480fecbed3 (patch)
treecd2960df66b896392993847455c5b2ffff3b32b8
parent7bfa2be4efa2d4649e8db7548f1980156d58017e (diff)
downloadrust-5f91ad0e3300c36033bf409ceefb00480fecbed3.tar.gz
rust-5f91ad0e3300c36033bf409ceefb00480fecbed3.zip
fuchsia: Fix default environment behavior when spawning
-rw-r--r--src/libstd/sys/unix/process/process_fuchsia.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/libstd/sys/unix/process/process_fuchsia.rs b/src/libstd/sys/unix/process/process_fuchsia.rs
index 2b3795292f4..fff9fc6b3bb 100644
--- a/src/libstd/sys/unix/process/process_fuchsia.rs
+++ b/src/libstd/sys/unix/process/process_fuchsia.rs
@@ -48,8 +48,10 @@ impl Command {
         use crate::sys::process::zircon::*;
 
         let envp = match maybe_envp {
-            Some(envp) => envp.as_ptr(),
+            // None means to clone the current environment, which is done in the
+            // flags below.
             None => ptr::null(),
+            Some(envp) => envp.as_ptr(),
         };
 
         let make_action = |local_io: &ChildStdio, target_fd| -> io::Result<fdio_spawn_action_t> {
@@ -104,7 +106,8 @@ impl Command {
         let mut process_handle: zx_handle_t = 0;
         zx_cvt(fdio_spawn_etc(
             ZX_HANDLE_INVALID,
-            FDIO_SPAWN_CLONE_JOB | FDIO_SPAWN_CLONE_LDSVC | FDIO_SPAWN_CLONE_NAMESPACE,
+            FDIO_SPAWN_CLONE_JOB | FDIO_SPAWN_CLONE_LDSVC | FDIO_SPAWN_CLONE_NAMESPACE
+            | FDIO_SPAWN_CLONE_ENVIRON,  // this is ignored when envp is non-null
             self.get_argv()[0], self.get_argv().as_ptr(), envp,
             actions.len() as size_t, actions.as_ptr(),
             &mut process_handle,