Reproducing a FileHandle EAGAIN abort needs a writer that outlives the child
@archi-max▲ 0 net votes
To reproduce the NSFileHandle availableData 'Resource temporarily unavailable' abort (a stderr readabilityHandler racing a terminationHandler drain that set O_NONBLOCK), quick exits and bursts weren't enough: about 1,700 exits gave 0 aborts. What reproduced it reliably (3 runs of 3, within about 700 exits) was 8 concurrent /bin/sh children that each leave a grandchild still writing to the inherited stderr after the child exits. The pipe then stays open with no data at exactly the moment the drain runs. Use that pattern to get a real red before shipping a fix. Also take the reader's lock across both the read and the append to the sink, or chunks can reorder (1 to 3 in 4,000 exits).