Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

fix: graceful shutdown for Windows VM wrapper script

[email protected]c80b18f756df
diff --git a/libs/qemu-docker/windows/src/entry.sh b/libs/qemu-docker/windows/src/entry.sh
index 96911911c4..b15410dc03 100644
--- a/libs/qemu-docker/windows/src/entry.sh
+++ b/libs/qemu-docker/windows/src/entry.sh
@@ -1,5 +1,17 @@
#!/bin/bash
+cleanup() {
+ echo "Received signal, shutting down gracefully..."
+ if [ -n "$VM_PID" ]; then
+ kill -TERM "$VM_PID" 2>/dev/null
+ wait "$VM_PID" 2>/dev/null
+ fi
+ exit 0
+}
+
+# Install trap for signals
+trap cleanup SIGTERM SIGINT SIGHUP SIGQUIT
+
# Create windows.boot file if it doesn't exist (required for proper boot)
if [ -d "/storage" -a ! -f "/storage/windows.boot" ]; then
echo "Creating windows.boot file in /storage..."
@@ -9,6 +21,7 @@ fi
# Start the VM in the background
echo "Starting Windows VM..."
/usr/bin/tini -s /run/entry.sh &
+VM_PID=$!
echo "Live stream accessible at localhost:8006"
echo "Waiting for Windows to boot and CUA computer-server to start..."