From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/process/fds-are-cloexec.rs | 82 ---------------------------------- 1 file changed, 82 deletions(-) delete mode 100644 src/test/ui/process/fds-are-cloexec.rs (limited to 'src/test/ui/process/fds-are-cloexec.rs') diff --git a/src/test/ui/process/fds-are-cloexec.rs b/src/test/ui/process/fds-are-cloexec.rs deleted file mode 100644 index 4482b7032..000000000 --- a/src/test/ui/process/fds-are-cloexec.rs +++ /dev/null @@ -1,82 +0,0 @@ -// run-pass -// ignore-windows -// ignore-android -// ignore-emscripten no processes -// ignore-haiku -// ignore-sgx no processes - -#![feature(rustc_private)] - -extern crate libc; - -use std::env; -use std::fs::File; -use std::io; -use std::net::{TcpListener, TcpStream, UdpSocket}; -use std::os::unix::prelude::*; -use std::process::{Command, Stdio}; -use std::thread; - -fn main() { - let args = env::args().collect::>(); - if args.len() == 1 { - parent() - } else { - child(&args) - } -} - -fn parent() { - let file = File::open(env::current_exe().unwrap()).unwrap(); - let tcp1 = TcpListener::bind("127.0.0.1:0").unwrap(); - let tcp2 = tcp1.try_clone().unwrap(); - let addr = tcp1.local_addr().unwrap(); - let t = thread::spawn(move || TcpStream::connect(addr).unwrap()); - let tcp3 = tcp1.accept().unwrap().0; - let tcp4 = t.join().unwrap(); - let tcp5 = tcp3.try_clone().unwrap(); - let tcp6 = tcp4.try_clone().unwrap(); - let udp1 = UdpSocket::bind("127.0.0.1:0").unwrap(); - let udp2 = udp1.try_clone().unwrap(); - - let mut child = Command::new(env::args().next().unwrap()) - .arg("100") - .stdout(Stdio::piped()) - .stdin(Stdio::piped()) - .stderr(Stdio::piped()) - .spawn().unwrap(); - let pipe1 = child.stdin.take().unwrap(); - let pipe2 = child.stdout.take().unwrap(); - let pipe3 = child.stderr.take().unwrap(); - - - let status = Command::new(env::args().next().unwrap()) - .arg(file.as_raw_fd().to_string()) - .arg(tcp1.as_raw_fd().to_string()) - .arg(tcp2.as_raw_fd().to_string()) - .arg(tcp3.as_raw_fd().to_string()) - .arg(tcp4.as_raw_fd().to_string()) - .arg(tcp5.as_raw_fd().to_string()) - .arg(tcp6.as_raw_fd().to_string()) - .arg(udp1.as_raw_fd().to_string()) - .arg(udp2.as_raw_fd().to_string()) - .arg(pipe1.as_raw_fd().to_string()) - .arg(pipe2.as_raw_fd().to_string()) - .arg(pipe3.as_raw_fd().to_string()) - .status() - .unwrap(); - assert!(status.success()); - child.wait().unwrap(); -} - -fn child(args: &[String]) { - let mut b = [0u8; 2]; - for arg in &args[1..] { - let fd: libc::c_int = arg.parse().unwrap(); - unsafe { - assert_eq!(libc::read(fd, b.as_mut_ptr() as *mut _, 2), -1); - assert_eq!(io::Error::last_os_error().raw_os_error(), - Some(libc::EBADF)); - } - } -} -- cgit v1.2.3