mirror of
https://gitlab.steamos.cloud/holo/steamos-manager.git
synced 2025-07-13 09:52:00 -04:00
process: script_exit_code should not leak output
This commit is contained in:
parent
370c801796
commit
4cc4c74ff0
1 changed files with 9 additions and 3 deletions
|
@ -8,14 +8,20 @@
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
use std::ffi::OsStr;
|
use std::ffi::OsStr;
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
|
use std::process::Stdio;
|
||||||
|
#[cfg(not(test))]
|
||||||
use tokio::process::Command;
|
use tokio::process::Command;
|
||||||
|
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
pub async fn script_exit_code(executable: &str, args: &[impl AsRef<OsStr>]) -> Result<i32> {
|
pub async fn script_exit_code(executable: &str, args: &[impl AsRef<OsStr>]) -> Result<i32> {
|
||||||
// Run given script and return the exit code
|
// Run given script and return the exit code
|
||||||
let mut child = Command::new(executable).args(args).spawn()?;
|
let output = Command::new(executable)
|
||||||
let status = child.wait().await?;
|
.args(args)
|
||||||
status.code().ok_or(anyhow!("Killed by signal"))
|
.stdout(Stdio::null())
|
||||||
|
.stderr(Stdio::null())
|
||||||
|
.output()
|
||||||
|
.await?;
|
||||||
|
output.status.code().ok_or(anyhow!("Killed by signal"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue