Skip to content

Commit e9b27e5

Browse files
authored
Rollup merge of rust-lang#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 fd61d06 + 9d8f117 commit e9b27e5

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Lines changed: 19 additions & 0 deletions
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-wasm 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").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+
}
Lines changed: 13 additions & 0 deletions
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-wasm 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)