The post-stop hook was set to `/dev/null` as a no-op. Its actual purpose
(see #436) is to make LXC suppress auto-respawning the container when the
guest reboots/crashes, since waydroid manages the session lifecycle itself
-- LXC suppresses the respawn when the post-stop hook exits non-zero, and
/dev/null "achieves" this only because it is not executable.
The side effect is that the hook fails on *every* container stop, including
a normal shutdown, logging an error that users routinely misdiagnose:
lxc-start: waydroid: utils.c: run_buffer: 569 Script exited with status 126
lxc-start: waydroid: start.c: lxc_end: 1178 Failed to run lxc.hook.post-stop for container "waydroid"
(Reproduced on LXC 7.0.0; status 126 is execve() of the non-executable
/dev/null.)
Replace it with a real post-stop script that keys off LXC_TARGET: exit 0 on
"stop" so a routine `waydroid session stop` is clean, and non-zero otherwise
(reboot, or an unset value on older LXC) to preserve the respawn-suppression.
The script path is substituted into the generated config in set_lxc_config(),
mirroring the existing LXCARCH handling.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
After 85843da (container: Make "waydroid-net.sh start" failure fatal)
this could result always failing to start unless you ran
"waydroid-net.sh stop" manually first; perhaps this should always be
stopped upon encountering errors?
The "default to waydroid0" was broken as awk never returned a non-zero
exit code if the file exists but no match was found. Also account for
the key being named lxc.network.link on older LXC versions so one still
has the ability to have a flexible Waydroid network configuration.