From cbcc42deb65ba306b7b78f9e896bbf41fff5672f Mon Sep 17 00:00:00 2001 From: Mikail Bagishov Date: Sun, 5 Jul 2020 23:36:35 +0300 Subject: Support nullable timeout in ppoll --- src/poll.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/poll.rs') diff --git a/src/poll.rs b/src/poll.rs index e276090e..be5bf224 100644 --- a/src/poll.rs +++ b/src/poll.rs @@ -130,16 +130,16 @@ pub fn poll(fds: &mut [PollFd], timeout: libc::c_int) -> Result { /// ([`poll(2)`](http://man7.org/linux/man-pages/man2/poll.2.html)) /// /// `ppoll` behaves like `poll`, but let you specify what signals may interrupt it -/// with the `sigmask` argument. +/// with the `sigmask` argument. If you want `ppoll` to block indefinitely, +/// specify `None` as `timeout` (it is like `timeout = -1` for `poll`). /// #[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 { - - +pub fn ppoll(fds: &mut [PollFd], timeout: Option, sigmask: SigSet) -> Result { + let timeout = timeout.as_ref().map_or(core::ptr::null(), |r| r.as_ref()); 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) -- cgit v1.2.3