Flush output of child process

前端 未结 2 456
萌比男神i
萌比男神i 2021-01-22 12:20

I created a child process via IPC::Open2.
I need to read from the stdout of this child process line by line.
Problem is, as the stdout of the child process

2条回答
  •  太阳男子
    2021-01-22 12:46

    Unfortunately Perl has no control over the buffering behavior of the programs it executes. Some systems have an unbuffer utility that can do this. If you have access to this tool, you could say

    my $pid = open2($out, $in, 'unbuffer ./child_process');
    

    There's a discussion here about the equivalent tools for Windows, but I couldn't say whether any of them are effective.

提交回复
热议问题