Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate the signalfd function. #1938

Merged
merged 1 commit into from
Dec 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ This project adheres to [Semantic Versioning](https://semver.org/).
- With I/O-safe type applied in `pty::OpenptyResult` and `pty::ForkptyResult`,
users no longer need to manually close the file descriptors in these types.
([#1921](https://github.com/nix-rust/nix/pull/1921))
- The `fd` argument to `sys::signalfd::signalfd` is now of type `Option<impl AsFd>`.
([#1874](https://github.com/nix-rust/nix/pull/1874))

### Fixed
### Removed
Expand All @@ -29,6 +27,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).
([#1855](https://github.com/nix-rust/nix/pull/1855))
- Removed deprecated net APIs.
([#1861](https://github.com/nix-rust/nix/pull/1861))
- `nix::sys::signalfd::signalfd` is deprecated. Use
`nix::sys::signalfd::SignalFd` instead.
([#1938](https://github.com/nix-rust/nix/pull/1938))

## [0.26.1] - 2022-11-29
### Fixed
Expand Down
9 changes: 7 additions & 2 deletions src/sys/signalfd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ pub const SIGNALFD_SIGINFO_SIZE: usize = mem::size_of::<siginfo>();
/// signalfd (the default handler will be invoked instead).
///
/// See [the signalfd man page for more information](https://man7.org/linux/man-pages/man2/signalfd.2.html)
#[deprecated(since = "0.27.0", note = "Use SignalFd instead")]
pub fn signalfd<F: AsFd>(fd: Option<F>, mask: &SigSet, flags: SfdFlags) -> Result<OwnedFd> {
_signalfd(fd, mask, flags)
}

fn _signalfd<F: AsFd>(fd: Option<F>, mask: &SigSet, flags: SfdFlags) -> Result<OwnedFd> {
let raw_fd = fd.map_or(-1, |x|x.as_fd().as_raw_fd());
unsafe {
Errno::result(libc::signalfd(
Expand Down Expand Up @@ -90,13 +95,13 @@ impl SignalFd {
}

pub fn with_flags(mask: &SigSet, flags: SfdFlags) -> Result<SignalFd> {
let fd = signalfd(None::<OwnedFd>, mask, flags)?;
let fd = _signalfd(None::<OwnedFd>, mask, flags)?;

Ok(SignalFd(fd))
}

pub fn set_mask(&mut self, mask: &SigSet) -> Result<()> {
signalfd(Some(self.0.as_fd()), mask, SfdFlags::empty()).map(drop)
_signalfd(Some(self.0.as_fd()), mask, SfdFlags::empty()).map(drop)
}

pub fn read_signal(&mut self) -> Result<Option<siginfo>> {
Expand Down