Skip to content

Commit a2e0b48

Browse files
committed
Auto merge of #70416 - mzohreva:mz/sgx-test, r=nikomatsakis
Process termination test for SGX The issue is described in fortanix/rust-sgx#109 cc @jethrogb
2 parents 769d12e + 2b3adc9 commit a2e0b48

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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+
// ignore-emscripten no threads support
6+
7+
use std::{net::TcpListener, sync::mpsc, thread};
8+
9+
fn main() {
10+
let (tx, rx) = mpsc::channel();
11+
thread::spawn(move || {
12+
let listen = TcpListener::bind("0.0.0.0:0").unwrap();
13+
tx.send(()).unwrap();
14+
while let Ok(_) = listen.accept() {}
15+
});
16+
rx.recv().unwrap();
17+
for _ in 0..3 { thread::yield_now(); }
18+
println!("Exiting main thread");
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// program should terminate when std::process::exit is called from any thread
2+
3+
// run-pass
4+
// ignore-emscripten no threads support
5+
6+
use std::{process, thread};
7+
8+
fn main() {
9+
let h = thread::spawn(|| {
10+
process::exit(0);
11+
});
12+
let _ = h.join();
13+
}

0 commit comments

Comments
 (0)