Skip to content

Commit db1fbd4

Browse files
committed
Process termination tests
Related issues: - fortanix/rust-sgx#109
1 parent 82e90d6 commit db1fbd4

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// program should terminate even if a thread is blocked on I/O.
2+
// https://github.com/fortanix/rust-sgx/issues/109
3+
4+
// run-pass
5+
6+
use std::{net::TcpListener, sync::mpsc, thread};
7+
8+
fn main() {
9+
let (tx, rx) = mpsc::channel();
10+
thread::spawn(move || {
11+
let listen = TcpListener::bind("0:0").unwrap();
12+
tx.send(()).unwrap();
13+
while let Ok(_) = listen.accept() {}
14+
});
15+
rx.recv().unwrap();
16+
for _ in 0..3 { thread::yield_now(); }
17+
println!("Exiting main thread");
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// program should terminate when std::process::exit is called from any thread
2+
3+
// run-pass
4+
5+
use std::{process, thread};
6+
7+
fn main() {
8+
let h = thread::spawn(|| {
9+
process::exit(0);
10+
});
11+
let _ = h.join();
12+
}

0 commit comments

Comments
 (0)