about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdam Lesinski <adamlesinski@google.com>2020-09-15 13:54:46 -0700
committerAdam Lesinski <adamlesinski@google.com>2020-09-15 13:54:46 -0700
commitfafb2e9de717c40b95e52889bb641b32c1dc6a1e (patch)
treec3b5fb10b64f2b7170a4ccf49fea7ad27ed679ec
parenta874956d940ecb3ed524b6176a171219ac4787ea (diff)
downloadrust-fafb2e9de717c40b95e52889bb641b32c1dc6a1e.tar.gz
rust-fafb2e9de717c40b95e52889bb641b32c1dc6a1e.zip
[fuchsia] Propagate the userspace UTC clock
On Fuchsia, spawning a subprocess does not automatically
clone all of the parent process' capabilities. UTC time on
Fuchsia is managed by a top-level userspace clock capability
that is cloned and passed to subprocesses.

This change ensures that any Rust subprocess gets access to the
UTC clock, if the parent had access to it. This is critical for
tests, which on Fuchsia, use panic=abort and spawn subprocesses
per test.
-rw-r--r--library/std/src/sys/unix/process/process_fuchsia.rs3
-rw-r--r--library/std/src/sys/unix/process/zircon.rs1
2 files changed, 3 insertions, 1 deletions
diff --git a/library/std/src/sys/unix/process/process_fuchsia.rs b/library/std/src/sys/unix/process/process_fuchsia.rs
index 6daf2885bae..fab27cd9f70 100644
--- a/library/std/src/sys/unix/process/process_fuchsia.rs
+++ b/library/std/src/sys/unix/process/process_fuchsia.rs
@@ -118,7 +118,8 @@ impl Command {
             FDIO_SPAWN_CLONE_JOB
                 | FDIO_SPAWN_CLONE_LDSVC
                 | FDIO_SPAWN_CLONE_NAMESPACE
-                | FDIO_SPAWN_CLONE_ENVIRON, // this is ignored when envp is non-null
+                | FDIO_SPAWN_CLONE_ENVIRON // this is ignored when envp is non-null
+                | FDIO_SPAWN_CLONE_UTC_CLOCK,
             self.get_program().as_ptr(),
             self.get_argv().as_ptr(),
             envp,
diff --git a/library/std/src/sys/unix/process/zircon.rs b/library/std/src/sys/unix/process/zircon.rs
index 750b8f0762a..69ec275c2b3 100644
--- a/library/std/src/sys/unix/process/zircon.rs
+++ b/library/std/src/sys/unix/process/zircon.rs
@@ -138,6 +138,7 @@ pub const FDIO_SPAWN_CLONE_LDSVC: u32 = 0x0002;
 pub const FDIO_SPAWN_CLONE_NAMESPACE: u32 = 0x0004;
 pub const FDIO_SPAWN_CLONE_STDIO: u32 = 0x0008;
 pub const FDIO_SPAWN_CLONE_ENVIRON: u32 = 0x0010;
+pub const FDIO_SPAWN_CLONE_UTC_CLOCK: u32 = 0x0020;
 pub const FDIO_SPAWN_CLONE_ALL: u32 = 0xFFFF;
 
 // fdio_spawn_etc actions