]> git.proxmox.com Git - rustc.git/blobdiff - src/test/ui/process/process-panic-after-fork.rs
New upstream version 1.57.0+dfsg1
[rustc.git] / src / test / ui / process / process-panic-after-fork.rs
index ad749371beac041c4e56b691f5973ae772c18d3f..1ccf6bb051c20593c0e4d6f90f04669fbe8673e3 100644 (file)
@@ -23,21 +23,6 @@ use std::sync::atomic::{AtomicU32, Ordering};
 
 use libc::c_int;
 
-#[cfg(not(target_os = "linux"))]
-fn getpid() -> u32 {
-    process::id()
-}
-
-/// We need to directly use the getpid syscall instead of using `process::id()`
-/// because the libc wrapper might return incorrect values after a process was
-/// forked.
-#[cfg(target_os = "linux")]
-fn getpid() -> u32 {
-    unsafe {
-        libc::syscall(libc::SYS_getpid) as _
-    }
-}
-
 /// This stunt allocator allows us to spot heap allocations in the child.
 struct PidChecking<A> {
     parent: A,
@@ -59,7 +44,7 @@ impl<A> PidChecking<A> {
     fn check(&self) {
         let require_pid = self.require_pid.load(Ordering::Acquire);
         if require_pid != 0 {
-            let actual_pid = getpid();
+            let actual_pid = process::id();
             if require_pid != actual_pid {
                 unsafe {
                     libc::raise(libc::SIGUSR1);