Skip to content

Commit

Permalink
Redirect socat stdout/stderr
Browse files Browse the repository at this point in the history
Redirect socat output to avoid breaking console apps.

Suggested-by: Asahi Lina <[email protected]>
Signed-off-by: Sergio Lopez <[email protected]>
  • Loading branch information
slp committed Jun 7, 2024
1 parent a243692 commit d0179f3
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion crates/krun-guest/src/pulse.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use std::collections::HashMap;
use std::env;
use std::fs;
use std::path::Path;
use std::process::Command;
use std::process::{Command, Stdio};

use anyhow::{Context, Result};
use utils::env::find_in_path;
use utils::stdio::make_stdout_stderr;

pub fn setup_pulse_proxy<P>(run_path: P) -> Result<()>
where
Expand All @@ -14,6 +17,9 @@ where
return Ok(());
};

let envs: HashMap<String, String> = env::vars().collect();
let (stdout, stderr) = make_stdout_stderr(&socat_path, &envs)?;

let run_path = run_path.as_ref();
let pulse_path = run_path.join("pulse");
fs::create_dir(&pulse_path)
Expand All @@ -27,6 +33,9 @@ where
.expect("pulse_path should not contain invalid UTF-8")
))
.arg("VSOCK-CONNECT:2:3333")
.stdin(Stdio::null())
.stdout(stdout)
.stderr(stderr)
.spawn()
.context("Failed to execute `socat` as child process")?;

Expand Down

0 comments on commit d0179f3

Please sign in to comment.