summaryrefslogtreecommitdiffstats
path: root/recipes-containers/vcontainer
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@gmail.com>2026-01-08 14:12:19 +0000
committerBruce Ashfield <bruce.ashfield@gmail.com>2026-02-09 03:32:52 +0000
commit1370e09b17128885542fec69e9cff8642029706d (patch)
tree45b85b593426959da29cf666ccb10fac4c2b0acc /recipes-containers/vcontainer
parent2f75879bd6e77e6c4eafe21deadb583a9f1e9061 (diff)
downloadmeta-virtualization-1370e09b17128885542fec69e9cff8642029706d.tar.gz
vcontainer-init: fix idle timeout detection to distinguish EOF from timeout
The read -t command returns different exit codes: - 0: successful read - 1: EOF (connection closed) - >128: timeout (typically 142) Previously, any empty result was treated as timeout, but when the host closes the connection after PING/PONG, read returns EOF immediately. This caused the daemon to shut down right after startup. Now we capture the exit code and only trigger idle shutdown when read actually times out (exit code > 128). Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'recipes-containers/vcontainer')
-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