fix: improve error handling when spawning child processes

This commit is contained in:
Kevin Yue committed 2026-04-16 22:30:08 +08:00
1 parent e4426df6a2
commit e4295a6ce8
4 files changed
+26 -30

No files matched your search

+6 -5
View File
@@ -69,11 +69,12 @@ impl<'a> GuiLauncher<'a> {
info!("Launching gpgui");
let mut non_root_cmd = cmd.into_non_root()?;
let result = non_root_cmd.kill_on_drop(true).stdin(Stdio::piped()).spawn();
if result.is_err() {
bail!("Failed to spawn {}: {}", self.program.display(), result.unwrap_err())
}
let mut child = result.unwrap();
let child = non_root_cmd.kill_on_drop(true).stdin(Stdio::piped()).spawn();
let mut child = match child {
Ok(child) => child,
Err(err) => bail!("Failed to spawn {}: {}", self.program.display(), err),
};
let Some(mut stdin) = child.stdin.take() else {
bail!("Failed to open stdin");
};