1
Fork 0

Process termination tests

Related issues:
- https://github.com/fortanix/rust-sgx/issues/109
This commit is contained in:
Mohsen Zohrevandi 2020-03-25 19:28:14 -07:00
parent 82e90d6426
commit db1fbd4a11
2 changed files with 30 additions and 0 deletions

View file

@ -0,0 +1,18 @@
// program should terminate even if a thread is blocked on I/O.
// https://github.com/fortanix/rust-sgx/issues/109
// run-pass
use std::{net::TcpListener, sync::mpsc, thread};
fn main() {
let (tx, rx) = mpsc::channel();
thread::spawn(move || {
let listen = TcpListener::bind("0:0").unwrap();
tx.send(()).unwrap();
while let Ok(_) = listen.accept() {}
});
rx.recv().unwrap();
for _ in 0..3 { thread::yield_now(); }
println!("Exiting main thread");
}

View file

@ -0,0 +1,12 @@
// program should terminate when std::process::exit is called from any thread
// run-pass
use std::{process, thread};
fn main() {
let h = thread::spawn(|| {
process::exit(0);
});
let _ = h.join();
}