// Poll an idle pipe. Should timeout let nfds = loop_while_eintr!(poll(&mut fds, PollTimeout::from(100u8)));
assert_eq!(nfds, 0);
assert!(!fds[0].revents().unwrap().contains(PollFlags::POLLIN));
write(&w, b".").unwrap();
// Poll a readable pipe. Should return an event. let nfds = poll(&mut fds, PollTimeout::from(100u8)).unwrap();
assert_eq!(nfds, 1);
assert!(fds[0].revents().unwrap().contains(PollFlags::POLLIN));
}
// ppoll(2) is the same as poll except for how it handles timeouts and signals. // Repeating the test for poll(2) should be sufficient to check that our // bindings are correct. #[cfg(any(linux_android, freebsdlike))] #[test] fn test_ppoll() { use nix::poll::ppoll; use nix::sys::signal::SigSet; use nix::sys::time::{TimeSpec, TimeValLike};
let timeout = TimeSpec::milliseconds(1); let (r, w) = pipe().unwrap(); letmut fds = [PollFd::new(r.as_fd(), PollFlags::POLLIN)];
// Poll an idle pipe. Should timeout let sigset = SigSet::empty(); let nfds = loop_while_eintr!(ppoll(&mut fds, Some(timeout), Some(sigset)));
assert_eq!(nfds, 0);
assert!(!fds[0].revents().unwrap().contains(PollFlags::POLLIN));
write(&w, b".").unwrap();
// Poll a readable pipe. Should return an event. let nfds = ppoll(&mut fds, Some(timeout), None).unwrap();
assert_eq!(nfds, 1);
assert!(fds[0].revents().unwrap().contains(PollFlags::POLLIN));
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.