mirror of
https://github.com/lemonade-sdk/mac_linuxgpu.git
synced 2026-11-22 23:57:31 -10:00
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.