wait_for_bead: kill 9p read child on exit to prevent hang in execute_code
cmd.Run() waits for stdout pipe EOF, but the 9p read subprocess spawned by process substitution inherits the fd and keeps it open after bash exits. Capture the PID and kill it in an EXIT trap.
This commit is contained in:
parent
1df382c441
commit
32a3016f0d
|
|
@ -20,7 +20,11 @@ fi
|
|||
|
||||
EXPECTED_SOURCE="beads/$MOUNT"
|
||||
|
||||
while IFS= read -r line; do
|
||||
exec 3< <(9p read anvillm/events 2>/dev/null)
|
||||
EVENTS_PID=$!
|
||||
trap 'kill $EVENTS_PID 2>/dev/null; exec 3<&-' EXIT
|
||||
|
||||
while IFS= read -r line <&3; do
|
||||
type=$(echo "$line" | jq -r '.type // empty' 2>/dev/null)
|
||||
[ "$type" = "BeadReady" ] || continue
|
||||
|
||||
|
|
@ -30,4 +34,4 @@ while IFS= read -r line; do
|
|||
# Emit full bead data and exit — bot decides whether to claim
|
||||
echo "$line" | jq '.data'
|
||||
exit 0
|
||||
done < <(9p read anvillm/events 2>/dev/null)
|
||||
done
|
||||
|
|
|
|||
Reference in New Issue