Skip to content

Commit 39c570b

Browse files
committed
Support nullable timeout in ppoll
1 parent a777389 commit 39c570b

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/poll.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,17 @@ pub fn poll(fds: &mut [PollFd], timeout: libc::c_int) -> Result<libc::c_int> {
133133
/// with the `sigmask` argument.
134134
///
135135
#[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))]
136-
pub fn ppoll(fds: &mut [PollFd], timeout: TimeSpec, sigmask: SigSet) -> Result<libc::c_int> {
137-
136+
pub fn ppoll(fds: &mut [PollFd], timeout: Option<TimeSpec>, sigmask: SigSet) -> Result<libc::c_int> {
137+
let timeout = &timeout;
138+
let timeout = match timeout {
139+
Some(t) => t.as_ref(),
140+
None => core::ptr::null()
141+
};
138142

139143
let res = unsafe {
140144
libc::ppoll(fds.as_mut_ptr() as *mut libc::pollfd,
141145
fds.len() as libc::nfds_t,
142-
timeout.as_ref(),
146+
timeout,
143147
sigmask.as_ref())
144148
};
145149
Errno::result(res)

0 commit comments

Comments
 (0)