[Catalyst] Test server as a child process
Jason Kohles
email at jasonkohles.com
Tue Jul 31 18:41:23 GMT 2007
On Jul 31, 2007, at 7:15 AM, Ivan Fomichev wrote:
> 2007/7/31, Peter Edwards <peter at dragonstaff.com>:
>> Try using IPC::Run. I can see the "You can connect" message when
>> using it to
>> run scripts/myapp_server.pl (I guess it goes through ptys?)
>
> I've found the root of the evil.
> IPC::Run won't help here :-(
> The pipe is not autoflushed.
> If you put '$|++' in script/myapp_server.pl, everything works all
> right.
> BTW, is there a way to force autoflush for a Perl script executed in a
> child process, e. g. through environment variables, command line
> options or whatever?
>
Actually, IPC::Run will help, if you tell it to use pseudo-ttys
instead of pipes for the communication. If perl belives it's output
is going to a tty, then it won't buffer as it would if the output is
a pipe. Using Expect or IO::Pty directly, or something else that
makes the subprocess believe it is connected to a terminal will have
the same effect...
use IPC::Run qw( run );
run( "script/myapp_server.pl", '<pty<', \$in, '>pty>', $out_and_err );
--
Jason Kohles
email at jasonkohles.com
http://www.jasonkohles.com/
"A witty saying proves nothing." -- Voltaire
More information about the Catalyst
mailing list