Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/commands/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ pub async fn cleanup_vm(
data_dir: &Path,
health_cancel_token: Option<tokio_util::sync::CancellationToken>,
health_monitor_handle: Option<JoinHandle<()>>,
output_listener_handle: Option<JoinHandle<Vec<(String, String)>>>,
) {
info!("cleaning up resources");

Expand All @@ -306,6 +307,11 @@ pub async fn cleanup_vm(
}
}

// Abort output listener task if still running
if let Some(handle) = output_listener_handle {
handle.abort();
}

// Cancel VolumeServer tasks
for handle in volume_server_handles {
handle.abort();
Expand Down
3 changes: 2 additions & 1 deletion src/commands/podman.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ async fn cmd_podman_run(args: RunArgs) -> Result<()> {
};

// For non-TTY mode, use async output listener
let _output_handle = if !tty_mode {
let output_handle = if !tty_mode {
let socket_path = output_socket_path.clone();
let vm_id_clone = vm_id.clone();
Some(tokio::spawn(async move {
Expand Down Expand Up @@ -1642,6 +1642,7 @@ async fn cmd_podman_run(args: RunArgs) -> Result<()> {
&data_dir,
Some(health_cancel_token),
Some(health_monitor_handle),
output_handle, // abort output listener task
)
.await;

Expand Down
4 changes: 3 additions & 1 deletion src/commands/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ pub async fn cmd_snapshot_run(args: SnapshotRunArgs) -> Result<()> {
};

// For non-TTY mode, use async output listener
let _output_handle = if !tty_mode {
let output_handle = if !tty_mode {
let socket_path = output_socket_path.clone();
let vm_id_clone = vm_id.clone();
Some(tokio::spawn(async move {
Expand Down Expand Up @@ -839,6 +839,7 @@ pub async fn cmd_snapshot_run(args: SnapshotRunArgs) -> Result<()> {
&data_dir,
None, // no health monitor in exec path
None,
output_handle, // abort output listener task
)
.await;

Expand Down Expand Up @@ -964,6 +965,7 @@ pub async fn cmd_snapshot_run(args: SnapshotRunArgs) -> Result<()> {
&data_dir,
Some(health_cancel_token),
Some(health_monitor_handle),
output_handle, // abort output listener task
)
.await;

Expand Down
Loading