Transfer ownership of FD

Signed-off-by: James Sturtevant <jstur@microsoft.com>
This commit is contained in:
James Sturtevant 2024-03-12 15:53:31 +00:00 committed by Maksym Pavlenko
parent d32d023eb3
commit b15a1dd0c9
1 changed files with 2 additions and 3 deletions

View File

@ -17,7 +17,7 @@
use std::{ use std::{
convert::TryFrom, convert::TryFrom,
env, env,
os::unix::{fs::FileTypeExt, io::AsRawFd, net::UnixListener}, os::unix::{fs::FileTypeExt, net::UnixListener},
path::Path, path::Path,
process, process,
process::{Command, Stdio}, process::{Command, Stdio},
@ -285,7 +285,7 @@ pub async fn spawn(opts: StartOpts, grouping: &str, vars: Vec<(&str, &str)>) ->
&opts.address, &opts.address,
]) ])
.fd_mappings(vec![FdMapping { .fd_mappings(vec![FdMapping {
parent_fd: listener.as_raw_fd(), parent_fd: listener.into(),
child_fd: SOCKET_FD, child_fd: SOCKET_FD,
}])?; }])?;
if opts.debug { if opts.debug {
@ -296,7 +296,6 @@ pub async fn spawn(opts: StartOpts, grouping: &str, vars: Vec<(&str, &str)>) ->
let _child = command.spawn().map_err(io_error!(e, "spawn shim"))?; let _child = command.spawn().map_err(io_error!(e, "spawn shim"))?;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
crate::cgroup::set_cgroup_and_oom_score(_child.id())?; crate::cgroup::set_cgroup_and_oom_score(_child.id())?;
std::mem::forget(listener);
Ok(address) Ok(address)
} }