$ strace -etrace=select,read ./754685.pl >/dev/null ... select(16, [6 9], NULL, NULL, {0, 0}) = 1 (in [6], left {0, 0}) read(6, "1\n", 4096) = 2 select(16, [6 9], NULL, NULL, {0, 0}) = 0 (Timeout) select(16, [6 9], NULL, NULL, {0, 0}) = 1 (in [6], left {0, 0}) read(6, "2\n", 4096) = 2 select(16, [6 9], NULL, NULL, {0, 0}) = 0 (Timeout) select(16, [6 9], NULL, NULL, {0, 0}) = 1 (in [6], left {0, 0}) read(6, "3\n", 4096) = 2 select(16, [6 9], NULL, NULL, {0, 0}) = 0 (Timeout) --- SIGCHLD (Child exited) @ 0 (0) --- select(16, [6 9], NULL, NULL, {0, 0}) = 2 (in [6 9], left {0, 0}) read(6, "4\n", 4096) = 2 read(9, "0\n", 4096) = 2 select(16, [6 9], NULL, NULL, {0, 0}) = 0 (Timeout) --- SIGCHLD (Child exited) @ 0 (0) --- select(16, [6 9], NULL, NULL, {0, 0}) = 2 (in [6 9], left {0, 0}) read(6, "foo\nbar\n", 4096) = 8 <--- !! read(9, "0\n", 4096) = 2 select(16, [6 9], NULL, NULL, {0, 0}) = 0 (Timeout) #### pipe $reader, $writer; $reader->blocking(0); ... if (fileno($fh) == fileno($reader)) { read $reader, my $line, 1e5; $output .= $line; } ...