Consider the following script:
use IO::File;
$| = 1;
my ($handle, $pid) = myPipe();
if ($pid == 0) {
print \"$$\";
sleep 5;
exit;
}
print \"child: \".
Flushing the pipe doesn't happen on any fixed schedule. The only two ways that you can force the pipe to flush is by exiting the child process (which is what you're doing now), or explicitly calling flush. You can cause your handle to flush in perl by doing any of the following:
\n to the end of the child's message, which will (usually) cause the pipe to flush$| to 1, which causes the currently selected filehandle to auto-flushIO::Handle and calling $handle->flush.IO::Handle and setting $handle->autoflush = 1