Skip to content

Commit

Permalink
Remove broken test
Browse files Browse the repository at this point in the history
The test calls libc::getpid() in the pre_exec hook and asserts that the returned value is different from the PID of the parent.
However, libc::getpid() returns the wrong value.
Before version 2.25, glibc caches the PID of the current process with the goal of avoiding additional syscalls.
The cached value is only updated when the wrapper functions for fork or clone are called.
In PR rust-lang#81825 we switch to directly using the clone3 syscall.
Thus, the cache is not updated and getpid returns the PID of the parent.
source: https://man7.org/linux/man-pages/man2/getpid.2.html#NOTES
  • Loading branch information
voidc committed Mar 25, 2021
1 parent 58c1352 commit 8bc4de7
Showing 1 changed file with 0 additions and 18 deletions.
18 changes: 0 additions & 18 deletions src/test/ui/command/command-pre-exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,6 @@ fn main() {
};
assert_eq!(output.raw_os_error(), Some(102));

let pid = unsafe { libc::getpid() };
assert!(pid >= 0);
let output = unsafe {
Command::new(&me)
.arg("empty")
.pre_exec(move || {
let child = libc::getpid();
assert!(child >= 0);
assert!(pid != child);
Ok(())
})
.output()
.unwrap()
};
assert!(output.status.success());
assert!(output.stderr.is_empty());
assert!(output.stdout.is_empty());

let mem = Arc::new(AtomicUsize::new(0));
let mem2 = mem.clone();
let output = unsafe {
Expand Down

0 comments on commit 8bc4de7

Please sign in to comment.