rust/src/test/run-pass/pipe-detect-term.rs

45 lines
798 B
Rust
Raw Normal View History

// Make sure that we can detect when one end of the pipe is closed.
// xfail-pretty
// xfail-win32
use std;
import std::timer::sleep;
import std::uv;
import pipes::{try_recv, recv};
proto! oneshot (
waiting:send {
signal -> !
}
)
fn main() {
let iotask = uv::global_loop::get();
pipes::spawn_service(oneshot::init, |p| {
2012-08-06 14:34:08 -05:00
match try_recv(p) {
2012-08-20 14:23:37 -05:00
Some(*) => { fail }
None => { }
}
});
sleep(iotask, 100);
task::spawn_unlinked(failtest);
}
// Make sure the right thing happens during failure.
fn failtest() {
let (c, p) = oneshot::init();
do task::spawn_with(c) |_c| {
fail;
}
2012-08-22 19:24:52 -05:00
error!("%?", recv(p));
// make sure we get killed if we missed it in the receive.
loop { task::yield() }
}