Skip to content

Commit

Permalink
Merge pull request #55 from OSInside/fix_blocking_io_buffer
Browse files Browse the repository at this point in the history
Fixed podman call dead lock
  • Loading branch information
schaefi authored Dec 13, 2024
2 parents 07a6262 + 651dfd4 commit 1f7c213
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
4 changes: 4 additions & 0 deletions doc/podman-pilot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ OPTIONS
even if there are files missing. This can lead to a non functional
instance of course, you have been warned.

%interactive

Use when running interactive processes like a shell

DEBUGGING
---------

Expand Down
25 changes: 17 additions & 8 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 @@ -477,8 +478,15 @@ pub fn call_instance(

let RuntimeSection { resume, .. } = config().runtime();

let pilot_options = Lookup::get_pilot_run_options();
let mut interactive = false;
if pilot_options.contains_key("%interactive") {
interactive = true;
}

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,18 +516,19 @@ pub fn call_instance(
if Lookup::is_debug() {
debug!("{:?}", call.get_args());
}
if action == "rm" || action == "rm_force" {
match call.perform() {
if interactive {
call.status()?;
} else {
match call.output() {
Ok(output) => {
output
}
let _ = io::stdout().write_all(&output.stdout);
let _ = io::stderr().write_all(&output.stderr);
},
Err(_) => {
let _ = Container::podman_setup_permissions();
call.perform()?
call.output()?;
}
};
} else {
call.status()?;
}
Ok(())
}
Expand Down

0 comments on commit 1f7c213

Please sign in to comment.