mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
During development, it is common to cancel a running test and rerun it after making changes. However, pressing Ctrl+C while dev_cli.sh runs long-running container commands (wget, qemu-img, cargo build, etc.) does not reliably terminate the process. Bash defers signal handling while a foreground process is running, so the trap only fires after the docker run command returns. This makes it difficult to cancel and restart quickly. Fix this by introducing a run_container() wrapper that runs docker in the background and uses 'wait', which is immediately interruptible by signals. A cleanup() trap handler is set for SIGINT and SIGTERM that kills the named container, the tracked background PID, and any remaining child processes. Each docker run invocation is assigned a unique --name based on the script PID (clh-dev-$$) to allow targeted cleanup. The interactive shell (cmd_shell) is left unwrapped since it needs foreground terminal I/O. Signed-off-by: Muminul Islam <muislam@microsoft.com>
27 KiB
Executable File
27 KiB
Executable File