Skip to content

Commit f698fd3

Browse files
committed
Remove several deprecated constants and functions
* `unistd::daemon` on Apple * `unistd::pipe2` on Apple * `sys::event::FilterFlag::NOTE_EXIT_REPARENTED` on Apple * `sys::event::FilterFlag::NOTE_REAP` on Apple * `sys::ptrace::ptrace` on Android and Linux All have been deprecated for more than two releases and one year.
1 parent a777389 commit f698fd3

File tree

5 files changed

+20
-85
lines changed

5 files changed

+20
-85
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).
6969
optional arguments.
7070
(#[1242](https://github.com/nix-rust/nix/pull/1242))
7171

72+
- Removed `unistd::daemon`, `unistd::pipe2`,
73+
`sys::event::FilterFlag::NOTE_EXIT_REPARENTED`, and
74+
`sys::event::FilterFlag::NOTE_REAP` on OSX and ios. Removed
75+
`sys::ptrace::ptrace` on Android and Linux.
76+
(#[1255](https://github.com/nix-rust/nix/pull/1255))
77+
7278
## [0.17.0] - 3 February 2020
7379
### Added
7480
- Add `CLK_TCK` to `SysconfVar`

src/sys/event.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,6 @@ libc_bitflags!(
128128
NOTE_EXEC;
129129
NOTE_EXIT;
130130
#[cfg(any(target_os = "macos", target_os = "ios"))]
131-
#[deprecated( since="0.14.0", note="Deprecated since OSX 10.9")]
132-
#[allow(deprecated)]
133-
NOTE_EXIT_REPARENTED;
134-
#[cfg(any(target_os = "macos", target_os = "ios"))]
135131
NOTE_EXITSTATUS;
136132
NOTE_EXTEND;
137133
#[cfg(any(target_os = "macos",
@@ -177,11 +173,6 @@ libc_bitflags!(
177173
NOTE_OOB;
178174
NOTE_PCTRLMASK;
179175
NOTE_PDATAMASK;
180-
#[cfg(any(target_os = "macos", target_os = "ios"))]
181-
#[cfg(any(target_os = "macos", target_os = "ios"))]
182-
#[deprecated( since="0.14.0", note="Deprecated since OSX 10.9")]
183-
#[allow(deprecated)]
184-
NOTE_REAP;
185176
NOTE_RENAME;
186177
NOTE_REVOKE;
187178
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "freebsd"))]

src/sys/ptrace/linux.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -168,22 +168,6 @@ libc_bitflags! {
168168
}
169169
}
170170

171-
/// Performs a ptrace request. If the request in question is provided by a specialised function
172-
/// this function will return an unsupported operation error.
173-
#[deprecated(
174-
since="0.10.0",
175-
note="usages of `ptrace()` should be replaced with the specialized helper functions instead"
176-
)]
177-
pub unsafe fn ptrace(request: Request, pid: Pid, addr: AddressType, data: *mut c_void) -> Result<c_long> {
178-
use self::Request::*;
179-
match request {
180-
PTRACE_PEEKTEXT | PTRACE_PEEKDATA | PTRACE_GETSIGINFO |
181-
PTRACE_GETEVENTMSG | PTRACE_SETSIGINFO | PTRACE_SETOPTIONS |
182-
PTRACE_POKETEXT | PTRACE_POKEDATA | PTRACE_KILL => Err(Error::UnsupportedOperation),
183-
_ => ptrace_other(request, pid, addr, data)
184-
}
185-
}
186-
187171
fn ptrace_peek(request: Request, pid: Pid, addr: AddressType, data: *mut c_void) -> Result<c_long> {
188172
let ret = unsafe {
189173
Errno::clear();

src/unistd.rs

Lines changed: 6 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -867,12 +867,12 @@ pub fn execveat(dirfd: RawFd, pathname: &CStr, args: &[&CStr],
867867
/// descriptors will remain identical after daemonizing.
868868
/// * `noclose = false`: The process' stdin, stdout, and stderr will point to
869869
/// `/dev/null` after daemonizing.
870-
#[cfg_attr(any(target_os = "macos", target_os = "ios"), deprecated(
871-
since="0.14.0",
872-
note="Deprecated in MacOSX 10.5"
873-
))]
874-
#[cfg_attr(any(target_os = "macos", target_os = "ios"), allow(deprecated))]
875-
#[cfg(not(target_os = "redox"))]
870+
#[cfg(any(target_os = "android",
871+
target_os = "dragonfly",
872+
target_os = "freebsd",
873+
target_os = "linux",
874+
target_os = "netbsd",
875+
target_os = "openbsd"))]
876876
pub fn daemon(nochdir: bool, noclose: bool) -> Result<()> {
877877
let res = unsafe { libc::daemon(nochdir as c_int, noclose as c_int) };
878878
Errno::result(res).map(drop)
@@ -1083,60 +1083,6 @@ pub fn pipe2(flags: OFlag) -> Result<(RawFd, RawFd)> {
10831083
unsafe { Ok((fds.assume_init()[0], fds.assume_init()[1])) }
10841084
}
10851085

1086-
/// Like `pipe`, but allows setting certain file descriptor flags.
1087-
///
1088-
/// The following flags are supported, and will be set after the pipe is
1089-
/// created:
1090-
///
1091-
/// `O_CLOEXEC`: Set the close-on-exec flag for the new file descriptors.
1092-
/// `O_NONBLOCK`: Set the non-blocking flag for the ends of the pipe.
1093-
#[cfg(any(target_os = "ios", target_os = "macos"))]
1094-
#[deprecated(
1095-
since="0.10.0",
1096-
note="pipe2(2) is not actually atomic on these platforms. Use pipe(2) and fcntl(2) instead"
1097-
)]
1098-
pub fn pipe2(flags: OFlag) -> Result<(RawFd, RawFd)> {
1099-
let mut fds = mem::MaybeUninit::<[c_int; 2]>::uninit();
1100-
1101-
let res = unsafe { libc::pipe(fds.as_mut_ptr() as *mut c_int) };
1102-
1103-
Errno::result(res)?;
1104-
1105-
unsafe {
1106-
pipe2_setflags(fds.assume_init()[0], fds.assume_init()[1], flags)?;
1107-
1108-
Ok((fds.assume_init()[0], fds.assume_init()[1]))
1109-
}
1110-
}
1111-
1112-
#[cfg(any(target_os = "ios", target_os = "macos"))]
1113-
fn pipe2_setflags(fd1: RawFd, fd2: RawFd, flags: OFlag) -> Result<()> {
1114-
use crate::fcntl::FcntlArg::F_SETFL;
1115-
1116-
let mut res = Ok(0);
1117-
1118-
if flags.contains(OFlag::O_CLOEXEC) {
1119-
res = res
1120-
.and_then(|_| fcntl(fd1, F_SETFD(FdFlag::FD_CLOEXEC)))
1121-
.and_then(|_| fcntl(fd2, F_SETFD(FdFlag::FD_CLOEXEC)));
1122-
}
1123-
1124-
if flags.contains(OFlag::O_NONBLOCK) {
1125-
res = res
1126-
.and_then(|_| fcntl(fd1, F_SETFL(OFlag::O_NONBLOCK)))
1127-
.and_then(|_| fcntl(fd2, F_SETFL(OFlag::O_NONBLOCK)));
1128-
}
1129-
1130-
match res {
1131-
Ok(_) => Ok(()),
1132-
Err(e) => {
1133-
let _ = close(fd1);
1134-
let _ = close(fd2);
1135-
Err(e)
1136-
}
1137-
}
1138-
}
1139-
11401086
/// Truncate a file to a specified length
11411087
///
11421088
/// See also

test/test_unistd.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,14 @@ fn test_pipe() {
561561

562562
// pipe2(2) is the same as pipe(2), except it allows setting some flags. Check
563563
// that we can set a flag.
564+
#[cfg(any(target_os = "android",
565+
target_os = "dragonfly",
566+
target_os = "emscripten",
567+
target_os = "freebsd",
568+
target_os = "linux",
569+
target_os = "redox",
570+
target_os = "netbsd",
571+
target_os = "openbsd"))]
564572
#[test]
565573
fn test_pipe2() {
566574
let (fd0, fd1) = pipe2(OFlag::O_CLOEXEC).unwrap();

0 commit comments

Comments
 (0)