Files
geramyloveless dc0229043a Display agent: close a mirroring process's pipe at end of file
The daemon read each mirroring process's output with a readabilityHandler
that ignored end of file. At end of file availableData is empty and the
handler fires again at once, so the handler spun and the read descriptor
stayed open after every child exit. A daemon up for 29 hours ran at
170-260% CPU holding 2,556 pipes, and the child output stopped reaching
the log.

followOutput (DisplayAgent.swift) closes the read end and clears the
handler at end of file, after the last chunk. The termination handler no
longer clears the readability handler, which could drop the last lines
and leave the descriptor open. A pipe whose process failed to start is
closed.

A mirroring process no longer ends when its STATUS poll is answered
kIOReturnBusy: the daemon's STATUS and PROBE and the child's own IMPORT
share the driver's display gate, and a collision ended the mirror, which
the daemon restarted 10 s later. IMPORT is asked again for up to 2 s on
kIOReturnBusy. The daemon logs a mirroring process's exit status.

test-display-agent runs 20 short processes through followOutput and
checks every byte arrives, the end is seen once, no descriptor is left
open and nothing spins afterwards.
2026-10-08 13:03:11 -07:00
..