Skip to content

Commit 9797e0c

Browse files
committed
Deprecate the signalfd function.
The SignalFd type is just as capable and easier to use.
1 parent df5877c commit 9797e0c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ This project adheres to [Semantic Versioning](https://semver.org/).
1919
- With I/O-safe type applied in `pty::OpenptyResult` and `pty::ForkptyResult`,
2020
users no longer need to manually close the file descriptors in these types.
2121
([#1921](https://github.com/nix-rust/nix/pull/1921))
22-
- The `fd` argument to `sys::signalfd::signalfd` is now of type `Option<impl AsFd>`.
23-
([#1874](https://github.com/nix-rust/nix/pull/1874))
2422

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

3334
## [0.26.1] - 2022-11-29
3435
### Fixed

src/sys/signalfd.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ pub const SIGNALFD_SIGINFO_SIZE: usize = mem::size_of::<siginfo>();
4444
/// signalfd (the default handler will be invoked instead).
4545
///
4646
/// See [the signalfd man page for more information](https://man7.org/linux/man-pages/man2/signalfd.2.html)
47+
#[deprecated(since = "0.27.0", note = "Use SignalFd instead")]
4748
pub fn signalfd<F: AsFd>(fd: Option<F>, mask: &SigSet, flags: SfdFlags) -> Result<OwnedFd> {
49+
_signalfd(fd, mask, flags)
50+
}
51+
52+
fn _signalfd<F: AsFd>(fd: Option<F>, mask: &SigSet, flags: SfdFlags) -> Result<OwnedFd> {
4853
let raw_fd = fd.map_or(-1, |x|x.as_fd().as_raw_fd());
4954
unsafe {
5055
Errno::result(libc::signalfd(
@@ -90,13 +95,13 @@ impl SignalFd {
9095
}
9196

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

95100
Ok(SignalFd(fd))
96101
}
97102

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

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

0 commit comments

Comments
 (0)