Skip to content
Draft
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
10 changes: 9 additions & 1 deletion src/activation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use nix::sys::socket::{AddressFamily, SockaddrLike, SockaddrStorage};
use nix::sys::stat::fstat;
use std::convert::TryFrom;
use std::env;
use std::os::unix::io::{IntoRawFd, RawFd};
use std::os::unix::io::{FromRawFd, IntoRawFd, OwnedFd, RawFd};
use std::process;

/// Minimum FD number used by systemd for passing sockets.
Expand Down Expand Up @@ -271,6 +271,14 @@ impl IntoRawFd for FileDescriptor {
}
}

impl From<FileDescriptor> for OwnedFd {
fn from(fd: FileDescriptor) -> Self {
// SAFETY: FileDescriptor owns its fd, and IntoRawFd consumes it,
// so we have exclusive ownership of the raw fd at this point.
unsafe { OwnedFd::from_raw_fd(fd.into_raw_fd()) }
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
Loading