summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@gmail.com>2026-02-18 19:17:04 +0000
committerBruce Ashfield <bruce.ashfield@gmail.com>2026-02-26 01:05:01 +0000
commitbf5abfe3d55604c6b22416cc23cbfaba1ff7bee2 (patch)
treebbf9d7d6cb46d4031b19c5b6cba1dc23969b8617
parent6fe3f4cd1a1f408e0ef6b52b793927984449c9f6 (diff)
downloadmeta-virtualization-bf5abfe3d55604c6b22416cc23cbfaba1ff7bee2.tar.gz
vxn: add controlling terminal and clean up interactive output
Use setsid -c to establish a controlling terminal for the container shell, fixing "can't access tty; job control turned off" and enabling Ctrl-C signal delivery. Run in a subshell so setsid() succeeds without forking (PID 1 is already a session leader). Remove [vxn] diagnostic markers from interactive output now that terminal mode is working. Suppress mount warning on read-only input disk. Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
-rwxr-xr-xrecipes-containers/vcontainer/files/vxn-init.sh17
1 files changed, 8 insertions, 9 deletions
diff --git a/recipes-containers/vcontainer/files/vxn-init.sh b/recipes-containers/vcontainer/files/vxn-init.sh
index c22fa8ea..9c06e5c8 100755
--- a/recipes-containers/vcontainer/files/vxn-init.sh
+++ b/recipes-containers/vcontainer/files/vxn-init.sh
@@ -341,14 +341,16 @@ exec_in_container() {
341 fi 341 fi
342 342
343 if [ "$RUNTIME_INTERACTIVE" = "1" ]; then 343 if [ "$RUNTIME_INTERACTIVE" = "1" ]; then
344 # Interactive mode: connect stdin/stdout directly 344 # Interactive mode: establish a controlling terminal for job control.
345 # PID 1 is already a session leader, so setsid() would fork — run in
346 # a subshell (not session leader) where setsid() succeeds directly.
347 # The -c flag does ioctl(TIOCSCTTY) on stdin to set the controlling tty.
345 export TERM=linux 348 export TERM=linux
346 dmesg -n 1 2>/dev/null || true 349 dmesg -n 1 2>/dev/null || true
347 echo "[vxn] chroot: $rootfs $cmd" > /dev/console 2>/dev/null
348 if [ "$use_sh" = "true" ]; then 350 if [ "$use_sh" = "true" ]; then
349 chroot "$rootfs" /bin/sh -c "cd '$workdir' 2>/dev/null; exec $cmd" 351 (exec setsid -c chroot "$rootfs" /bin/sh -c "cd '$workdir' 2>/dev/null; exec $cmd")
350 else 352 else
351 chroot "$rootfs" $cmd 353 (exec setsid -c chroot "$rootfs" $cmd)
352 fi 354 fi
353 EXEC_EXIT_CODE=$? 355 EXEC_EXIT_CODE=$?
354 else 356 else
@@ -435,7 +437,7 @@ run_container_from_disk() {
435 437
436 # Mount input disk 438 # Mount input disk
437 mkdir -p /mnt/input 439 mkdir -p /mnt/input
438 if ! mount /dev/xvdb /mnt/input 2>/dev/null; then 440 if ! mount /dev/xvdb /mnt/input >/dev/null 2>&1; then
439 echo "===ERROR===" 441 echo "===ERROR==="
440 echo "Failed to mount /dev/xvdb" 442 echo "Failed to mount /dev/xvdb"
441 echo "===END===" 443 echo "===END==="
@@ -631,11 +633,9 @@ mount_base_filesystems
631# Check for quiet boot mode 633# Check for quiet boot mode
632check_quiet_boot 634check_quiet_boot
633 635
634# Interactive mode: suppress kernel console messages early (before mounts 636# Interactive mode: suppress guest kernel console messages early
635# that trigger loop device messages) and emit markers visible through PTY
636if [ "$QUIET_BOOT" = "1" ]; then 637if [ "$QUIET_BOOT" = "1" ]; then
637 dmesg -n 1 2>/dev/null || true 638 dmesg -n 1 2>/dev/null || true
638 echo "[vxn] init" > /dev/console 2>/dev/null
639fi 639fi
640 640
641log "=== vxn Init ===" 641log "=== vxn Init ==="
@@ -728,7 +728,6 @@ else
728 fi 728 fi
729 729
730 # Execute in container rootfs 730 # Execute in container rootfs
731 [ "$QUIET_BOOT" = "1" ] && echo "[vxn] exec: $EXEC_CMD" > /dev/console 2>/dev/null
732 exec_in_container "$CONTAINER_ROOT" "$EXEC_CMD" 731 exec_in_container "$CONTAINER_ROOT" "$EXEC_CMD"
733fi 732fi
734 733