Skip to content

Commit 34788b1

Browse files
committed
Added changelog entry and test for LocalPeerPid
1 parent 61bd3e2 commit 34788b1

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
1313
([#1912](https://github.com/nix-rust/nix/pull/1912))
1414
- Added `mq_timedreceive` to `::nix::mqueue`.
1515
([#1966])(https://github.com/nix-rust/nix/pull/1966)
16+
- Added `LocalPeerPid` to `nix::sys::socket::sockopt` for macOS. ([#1967](https://github.com/nix-rust/nix/pull/1967))
1617

1718
### Changed
1819

test/sys/test_sockopt.rs

+16
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@ pub fn test_local_peercred_stream() {
5454
assert_eq!(Gid::from_raw(xucred.groups()[0]), Gid::current());
5555
}
5656

57+
#[cfg(target_os = "macos")]
58+
#[test]
59+
pub fn test_local_peer_pid() {
60+
use nix::sys::socket::socketpair;
61+
62+
let (fd1, _fd2) = socketpair(
63+
AddressFamily::Unix,
64+
SockType::Stream,
65+
None,
66+
SockFlag::empty(),
67+
)
68+
.unwrap();
69+
let pid = getsockopt(fd1, sockopt::LocalPeerPid).unwrap();
70+
assert_eq!(pid, std::process::id() as _);
71+
}
72+
5773
#[cfg(target_os = "linux")]
5874
#[test]
5975
fn is_so_mark_functional() {

0 commit comments

Comments
 (0)