Skip to content

Commit b31d95d

Browse files
LTSCommerceclaude
andcommitted
Plan 00055: fix L2 LXC burner launch — detach spinner so it survives lxc-attach
podman + docker L2 blocks pass fully (detection, attribution, container_pid match, the reporting-only survive-assert, allowlist, DBus). The LXC block failed reading ground-truth PIDs: the spinner was launched as a plain `&` job under lxc-attach, which (a) kept the attach pipe's stdout fd open — stalling the command substitution — and (b) could be torn down with the attach session. - Launch via `nohup ... >/tmp/cw-burn.log 2>&1 &` so stdio is detached from the attach pipe (returns immediately) and the spinner ignores the session SIGHUP, surviving lxc-attach exit (reparented to container init). - Retry the ground-truth pgrep a few times (system-container init + detach lag). bash -n + shellcheck clean; qa-all green (345 files). Refs: CLAUDE/Plan/00055-container-process-watchdog Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 1a430d5 commit b31d95d

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

‎CLAUDE/Plan/00055-container-process-watchdog/acceptance.bash‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -370,15 +370,30 @@ run_lxc_block() {
370370
fi
371371
pass "$engine: started container '$burner'"
372372

373-
# Launch the bounded spinner inside the container (detached).
373+
# Launch the bounded spinner inside the container, fully DETACHED. A plain
374+
# `... &` job under lxc-attach is fragile: the backgrounded process keeps the
375+
# attach pipe's stdout fd open (so this command substitution would stall until
376+
# the burner's TTL elapsed), and it can be torn down with the attach session.
377+
# Redirecting its stdio to a log file inside the container frees the pipe (this
378+
# returns immediately), and `nohup` makes it ignore the session SIGHUP so it
379+
# survives lxc-attach exiting and is reparented to the container init.
374380
if ! out="$(sudo lxc-attach -n "$burner" -- sh -c \
375-
"timeout $BURNER_TTL_S sh -c 'while :; do :; done & while :; do :; done & wait' &" 2>&1)"; then
381+
"nohup timeout $BURNER_TTL_S sh -c 'while :; do :; done & while :; do :; done & wait' >/tmp/cw-burn.log 2>&1 &" 2>&1)"; then
376382
echo " note: lxc-attach spinner launch reported: $out" >&2
377383
fi
378-
sleep 2
379384

380-
if ! gt_pids="$(sudo lxc-attach -n "$burner" -- pgrep -f 'while' 2>&1)"; then
381-
fail "$engine: could not read ground-truth in-container PID: $gt_pids"
385+
# Ground truth: the in-container spinner PID(s). The system-container init plus
386+
# nohup detach can lag a beat, so retry a few times before giving up.
387+
gt_pids=""
388+
for _ in 1 2 3 4 5 6; do
389+
sleep 1
390+
if gt_pids="$(sudo lxc-attach -n "$burner" -- pgrep -f 'while' 2>&1)" && [ -n "$gt_pids" ]; then
391+
break
392+
fi
393+
gt_pids=""
394+
done
395+
if [ -z "$gt_pids" ]; then
396+
fail "$engine: could not read ground-truth in-container PID (spinner did not start or detach)"
382397
return 0
383398
fi
384399
gt_in_pid="$(printf '%s\n' "$gt_pids" | head -n1)"

0 commit comments

Comments
 (0)