Reputation: 21
I am having two separate scripts and I am to trying initiate the execution of one script(child process) from another script(parent process) using pipe mechanism such as open($fh, '-|', "./monitor.pl") here monitor.pl is the child process such that both of them executes asynchronously and at the same time. The output of the commands placed inside the while loop of the child process are written to the pipe handle continuously for that reason the buffer is getting filled up. So please suggest me the mechanism and appropriate location to flush the buffer such that the child process never hangs up as the buffer fills up.
Upvotes: 1
Views: 526
Reputation: 39158
See IO::Handle.
Automatically flush after writing:
$fh->autoflush(1);
Flush manually:
$fh->flush;
On Perl versions lower than 5.14
you also need to load the IO::Handle module:
use IO::Handle qw();
Upvotes: 1