]> git.lizzy.rs Git - rust.git/commitdiff
[fuchsia] Propagate the userspace UTC clock
authorAdam Lesinski <adamlesinski@google.com>
Tue, 15 Sep 2020 20:54:46 +0000 (13:54 -0700)
committerAdam Lesinski <adamlesinski@google.com>
Tue, 15 Sep 2020 20:54:46 +0000 (13:54 -0700)
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.

library/std/src/sys/unix/process/process_fuchsia.rs
library/std/src/sys/unix/process/zircon.rs

index 6daf2885baed0768e010cbd8698521b655da6e7a..fab27cd9f70855f04904cf16f463c3681bce14b5 100644 (file)
@@ -118,7 +118,8 @@ unsafe fn do_exec(
             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,
index 750b8f0762ae51ba72e2c97a92256801ca00b046..69ec275c2b318372151200ba05590f4e4c8aabcb 100644 (file)
@@ -138,6 +138,7 @@ pub fn fdio_spawn_etc(
 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