Skip to content

Commit

Permalink
Support nullable timeout in ppoll
Browse files Browse the repository at this point in the history
  • Loading branch information
MikailBag committed Jul 5, 2020
1 parent a777389 commit 39c570b
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/poll.rs
Expand Up @@ -133,13 +133,17 @@ pub fn poll(fds: &mut [PollFd], timeout: libc::c_int) -> Result<libc::c_int> {
/// with the `sigmask` argument.
///
#[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))]
pub fn ppoll(fds: &mut [PollFd], timeout: TimeSpec, sigmask: SigSet) -> Result<libc::c_int> {

pub fn ppoll(fds: &mut [PollFd], timeout: Option<TimeSpec>, sigmask: SigSet) -> Result<libc::c_int> {
let timeout = &timeout;
let timeout = match timeout {
Some(t) => t.as_ref(),
None => core::ptr::null()
};

let res = unsafe {
libc::ppoll(fds.as_mut_ptr() as *mut libc::pollfd,
fds.len() as libc::nfds_t,
timeout.as_ref(),
timeout,
sigmask.as_ref())
};
Errno::result(res)
Expand Down

0 comments on commit 39c570b

Please sign in to comment.