diff options
author | Mikail Bagishov <bagishov.mikail@yandex.ru> | 2020-07-05 23:36:35 +0300 |
---|---|---|
committer | Mikail Bagishov <bagishov.mikail@yandex.ru> | 2020-07-26 23:19:57 +0300 |
commit | cbcc42deb65ba306b7b78f9e896bbf41fff5672f (patch) | |
tree | 24a351ec31afcaf8a46fd52102e7a1dea0dc62d4 /src | |
parent | 57b6bd77002830526b1a8160d7c499584d2d2a8b (diff) | |
download | nix-cbcc42deb65ba306b7b78f9e896bbf41fff5672f.zip |
Support nullable timeout in ppoll
Diffstat (limited to 'src')
-rw-r--r-- | src/poll.rs | 10 |
1 files changed, 5 insertions, 5 deletions
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<libc::c_int> { /// ([`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<libc::c_int> { - - +pub fn ppoll(fds: &mut [PollFd], timeout: Option<TimeSpec>, sigmask: SigSet) -> Result<libc::c_int> { + 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) |