summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xrecipes-containers/vcontainer/files/vcontainer-init-common.sh14
1 files changed, 9 insertions, 5 deletions
diff --git a/recipes-containers/vcontainer/files/vcontainer-init-common.sh b/recipes-containers/vcontainer/files/vcontainer-init-common.sh
index 5bfee9b7..21bbe9db 100755
--- a/recipes-containers/vcontainer/files/vcontainer-init-common.sh
+++ b/recipes-containers/vcontainer/files/vcontainer-init-common.sh
@@ -329,7 +329,10 @@ run_daemon_mode() {
329 # Command loop with idle timeout 329 # Command loop with idle timeout
330 while true; do 330 while true; do
331 CMD_B64="" 331 CMD_B64=""
332 if read -t "$RUNTIME_IDLE_TIMEOUT" -r CMD_B64 <&3; then 332 read -t "$RUNTIME_IDLE_TIMEOUT" -r CMD_B64 <&3
333 READ_EXIT=$?
334
335 if [ $READ_EXIT -eq 0 ]; then
333 log "Received: '$CMD_B64'" 336 log "Received: '$CMD_B64'"
334 # Handle special commands 337 # Handle special commands
335 case "$CMD_B64" in 338 case "$CMD_B64" in
@@ -419,14 +422,15 @@ run_daemon_mode() {
419 422
420 log "Command completed (exit code: $EXEC_EXIT_CODE)" 423 log "Command completed (exit code: $EXEC_EXIT_CODE)"
421 else 424 else
422 # Read returned non-zero: either timeout or error 425 # Read returned non-zero: either timeout or EOF
423 if [ -z "$CMD_B64" ]; then 426 # Timeout returns >128 (typically 142), EOF returns 1
424 # Timeout expired with no data - shut down 427 if [ $READ_EXIT -gt 128 ]; then
428 # Actual timeout - shut down
425 log "Idle timeout (${RUNTIME_IDLE_TIMEOUT}s), shutting down..." 429 log "Idle timeout (${RUNTIME_IDLE_TIMEOUT}s), shutting down..."
426 echo "===IDLE_SHUTDOWN===" | cat >&3 430 echo "===IDLE_SHUTDOWN===" | cat >&3
427 break 431 break
428 fi 432 fi
429 # Empty line or other issue - just continue 433 # EOF or empty line - host closed connection, wait for reconnect
430 sleep 0.1 434 sleep 0.1
431 fi 435 fi
432 done 436 done