Skip to content

Commit

Permalink
Fixed podman call dead lock
Browse files Browse the repository at this point in the history
When calling the flake and stdout/stderr gets redirected into
a pipe like `flake | grep ... | cut ...` the pilot binary runs
in a dead lock because there is no reader/writer to feed the
pipe from the child process (podman) executed via the pilot.
This commit fixes it by making sure all data from the child
gets read first and then passed along to stdout/stderr of the
caller.
  • Loading branch information
schaefi committed Dec 12, 2024
1 parent 07a6262 commit 8c8e8d7
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions podman-pilot/src/podman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use flakes::command::{CommandError, CommandExtTrait};
use flakes::container::Container;
use flakes::config::get_podman_ids_dir;

use std::io;
use std::path::Path;
use std::process::{Command, Output, Stdio};
use std::env;
Expand Down Expand Up @@ -478,7 +479,8 @@ pub fn call_instance(
let RuntimeSection { resume, .. } = config().runtime();

let mut call = user.run("podman");
if action == "rm_force" {
if action == "rm" || action == "rm_force" {
call.stdout(Stdio::null());
call.arg("rm").arg("--force");
} else {
call.arg(action);
Expand Down Expand Up @@ -508,19 +510,16 @@ pub fn call_instance(
if Lookup::is_debug() {
debug!("{:?}", call.get_args());
}
if action == "rm" || action == "rm_force" {
match call.perform() {
Ok(output) => {
output
}
Err(_) => {
let _ = Container::podman_setup_permissions();
call.perform()?
}
};
} else {
call.status()?;
}
match call.output() {
Ok(output) => {
let _ = io::stdout().write_all(&output.stdout);
let _ = io::stderr().write_all(&output.stderr);
},
Err(_) => {
let _ = Container::podman_setup_permissions();
call.output()?;
}
};
Ok(())
}

Expand Down

0 comments on commit 8c8e8d7

Please sign in to comment.