summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-06-09 11:31:52 +0000
committerGitHub <noreply@github.com>2022-06-09 11:31:52 +0000
commit01a5927e2c9947bb9dd983cccb41f20573fb1527 (patch)
tree68c791012c3839f6a7fc8d97a30f80344eccc639
parentb3ba2b5f63ddafa1644452030c1fac9a9cdd2641 (diff)
parentc3081e4896344dbf0c27103a60c90eaa8d35715e (diff)
downloadnix-01a5927e2c9947bb9dd983cccb41f20573fb1527.zip
Merge #1739
1739: ppoll: make sigmask parameter optional r=rtzoeller a=stefano-garzarella ppoll(2) supports 'sigmask' as NULL. In that case no signal mask manipulation is performed. Let's make `sigmask` parameter of `nix::poll::ppoll` optional to allow that behaviour. Signed-off-by: Stefano Garzarella <sgarzare@redhat.com> Co-authored-by: Stefano Garzarella <sgarzare@redhat.com>
-rw-r--r--CHANGELOG.md2
-rw-r--r--src/poll.rs8
-rw-r--r--test/test_poll.rs4
3 files changed, 10 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 96befe3f..580bcbca 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -28,6 +28,8 @@ This project adheres to [Semantic Versioning](https://semver.org/).
* Changes the type of the `priority` arguments to `i32`.
* Changes the return type of `aio_return` to `usize`.
(#[1713](https://github.com/nix-rust/nix/pull/1713))
+- `nix::poll::ppoll`: `sigmask` parameter is now optional.
+ (#[1739](https://github.com/nix-rust/nix/pull/1739))
### Fixed
diff --git a/src/poll.rs b/src/poll.rs
index 6d332b03..3004d24c 100644
--- a/src/poll.rs
+++ b/src/poll.rs
@@ -151,20 +151,24 @@ feature! {
/// `ppoll` behaves like `poll`, but let you specify what signals may interrupt it
/// with the `sigmask` argument. If you want `ppoll` to block indefinitely,
/// specify `None` as `timeout` (it is like `timeout = -1` for `poll`).
+/// If `sigmask` is `None`, then no signal mask manipulation is performed,
+/// so in that case `ppoll` differs from `poll` only in the precision of the
+/// timeout argument.
///
#[cfg(any(target_os = "android", target_os = "dragonfly", target_os = "freebsd", target_os = "linux"))]
pub fn ppoll(
fds: &mut [PollFd],
timeout: Option<crate::sys::time::TimeSpec>,
- sigmask: crate::sys::signal::SigSet
+ sigmask: Option<crate::sys::signal::SigSet>
) -> Result<libc::c_int>
{
let timeout = timeout.as_ref().map_or(core::ptr::null(), |r| r.as_ref());
+ let sigmask = sigmask.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,
- sigmask.as_ref())
+ sigmask)
};
Errno::result(res)
}
diff --git a/test/test_poll.rs b/test/test_poll.rs
index e4b369f3..120e8e56 100644
--- a/test/test_poll.rs
+++ b/test/test_poll.rs
@@ -53,14 +53,14 @@ fn test_ppoll() {
// Poll an idle pipe. Should timeout
let sigset = SigSet::empty();
- let nfds = loop_while_eintr!(ppoll(&mut fds, Some(timeout), sigset));
+ let nfds = loop_while_eintr!(ppoll(&mut fds, Some(timeout), Some(sigset)));
assert_eq!(nfds, 0);
assert!(!fds[0].revents().unwrap().contains(PollFlags::POLLIN));
write(w, b".").unwrap();
// Poll a readable pipe. Should return an event.
- let nfds = ppoll(&mut fds, Some(timeout), SigSet::empty()).unwrap();
+ let nfds = ppoll(&mut fds, Some(timeout), None).unwrap();
assert_eq!(nfds, 1);
assert!(fds[0].revents().unwrap().contains(PollFlags::POLLIN));
}