diff --git a/CHANGELOG.md b/CHANGELOG.md index 41c6f255c4..932d2cc1f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). ([#508](https://github.com/nix-rust/nix/pull/508)) - Fixed the style of many bitflags and use `libc` in more places. ([#503](https://github.com/nix-rust/nix/pull/503)) +- Added `ppoll` in `::nix::poll` for Linux and Android + ([#520](https://github.com/nix-rust/nix/pull/520)) ### Changed - `epoll_ctl` now could accept None as argument `event` diff --git a/src/poll.rs b/src/poll.rs index 72988d8c3e..617a147c42 100644 --- a/src/poll.rs +++ b/src/poll.rs @@ -1,3 +1,6 @@ +use sys::time::TimeSpec; +use sys::signal::SigSet; + use libc; use {Errno, Result}; @@ -47,3 +50,15 @@ pub fn poll(fds: &mut [PollFd], timeout: libc::c_int) -> Result { Errno::result(res) } + +#[cfg(any(target_os = "linux", target_os = "android"))] +pub fn ppoll(fds: &mut [PollFd], timeout: TimeSpec, sigmask: SigSet) -> Result { + + let res = unsafe { + libc::ppoll(fds.as_mut_ptr() as *mut libc::pollfd, + fds.len() as libc::nfds_t, + timeout.as_ref(), + sigmask.as_ref()) + }; + Errno::result(res) +}