A rootless Android app that boots Alpine Linux: run containers (Podman/Docker/LXC) and GUI desktop apps.
#!/bin/sh
# Reads "RESIZE rows cols" lines from /dev/hvc1 (ctrl.sock) and applies
# them to /dev/hvc0 via stty. The Android side's libpodroid-bridge
# debounces SIGWINCH bursts and emits one line per stable size.
#
# Also writes the last-known size to /run/term_size so podroid-login
# can restore it after each getty respawn (virtio-console resets winsize
# to 0x0 every time the line is reopened).
#
# No `set -e`: this is a long-lived `while read` daemon. A transient stty
# failure (e.g. /dev/hvc0 momentarily unavailable during a getty respawn)
# or a tmpfs write hiccup must not terminate the daemon for the rest of
# the VM's life; start-stop-daemon --background won't respawn it.
# Wait for the virtio-console node to appear (timing varies)
for _i in $(seq 1 30); do
[ -c /dev/hvc1 ] && break
sleep 1
done
[ -c /dev/hvc1 ] || exit 0
while IFS= read -r _line; do
case "$_line" in
RESIZE\ *)
set -- $_line
# Reject empty / non-numeric / zero rows or cols before persisting:
# a malformed line must not stamp junk into /run/term_size (which
# podroid-login reads back) or stty a 0x0 winsize onto hvc0.
case "$2" in ''|*[!0-9]*|0) continue;; esac
case "$3" in ''|*[!0-9]*|0) continue;; esac
stty rows "$2" cols "$3" </dev/hvc0 2>/dev/null
printf '%s %s\n' "$2" "$3" > /run/term_size 2>/dev/null
;;
esac
done </dev/hvc1