Don't leak fds, and don't unset cloexec except/until needed (#3)
This may still leak fds in some error cases. That can be solved by using `OwnedFd` when the next Rust stable releases.
This commit is contained in:
parent
b614753cff
commit
cefd13692b
4 changed files with 52 additions and 32 deletions
|
|
@ -1,5 +1,6 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
use crate::process::{ProcessEvent, ProcessHandler};
|
||||
use std::os::unix::io::RawFd;
|
||||
use tokio::sync::mpsc::unbounded_channel;
|
||||
use tokio_util::sync::CancellationToken;
|
||||
use tracing::{Instrument, Span};
|
||||
|
|
@ -10,12 +11,13 @@ pub fn run_executable(
|
|||
executable: &'static str,
|
||||
args: Vec<String>,
|
||||
env_vars: Vec<(String, String)>,
|
||||
fds: Vec<RawFd>,
|
||||
) {
|
||||
let span_2 = span.clone();
|
||||
let (tx, mut rx) = unbounded_channel::<ProcessEvent>();
|
||||
tokio::spawn(
|
||||
async move {
|
||||
ProcessHandler::new(tx, &token).run(executable, args, env_vars, &span);
|
||||
ProcessHandler::new(tx, &token).run(executable, args, env_vars, fds, &span);
|
||||
while let Some(event) = rx.recv().await {
|
||||
match event {
|
||||
ProcessEvent::Started => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue