-
fix: stop telegram listener crash-loop from failed background commands
gates / consistency-and-conventions (push) Failing after 13sreleased this
2026-09-12 19:48:02 +02:00 A mapped command exiting non-zero (e.g. /capture -> ffmpeg with no
webcam, exit 254) killed the whole daemon: the CHLD trap only recorded
children that exited 0 (and wait -n inside a trap is unreliable on bash
5.2 anyway), so reap_commands fell back to a bare 'wait $pid' which
aborts the shell under set -euo pipefail before the exit code is
captured. systemd Restart=always then crash-looped (dead gaps + duplicate
command execution from getUpdates offset=0 restarts).- reap_commands: single reaper path, set -e safe wait with || rc=$?,
non-zero child exits now produce a normal reply with the real rc - persist the confirmed getUpdates offset to $CONFIG_DIR/telegram-listener.state
(LISTENER_STATE_FILE seam) and resume it on start, so a restart never
re-delivers an unconfirmed burst - new regression test t-telegram-listener-reap.sh (12 checks): 254-child
reap survives daemon, negative control proves the old idiom dies,
offset load/save resume + invalid fallback + empty-batch no-write
Downloads
- reap_commands: single reaper path, set -e safe wait with || rc=$?,