in reply to Re^3: Win32 Perl: inheriting redirected STDIN and STDOUT in a child process (select)
in thread Win32 Perl: inheriting redirected STDIN and STDOUT in a child process

Win32::Socketpair did the trick. Apparently pipes aren't handled well when redirecting STDIO.

The module does exactly the same thing to redirect the STDIN/STDOUT that I tried without success. The big difference was that it was using a network socket instead of a pipe.

For the record, I did have to set the handles to autoflush in both the client and server code in order for things to work properly.

Thanks for your help.

# In the server: use IO::Handle; my @command = ( 'perl', 'client.pl' ); my ($started, $fd)= winopen2( @command ); $fd->autoflush; # and the client: use IO::Handle; STDIN->autoflush; STDOUT->autoflush; print "$_" while <>;


TGI says moo

  • Comment on Re^4: Win32 Perl: inheriting redirected STDIN and STDOUT in a child process (select)
  • Download Code

Replies are listed 'Best First'.
Re^5: Win32 Perl: inheriting redirected STDIN and STDOUT in a child process (select)
by BrowserUk (Patriarch) on Oct 23, 2008 at 17:36 UTC
    I did have to set the handles to autoflush in both the client and server code in order for things to work properly.

    That sounds likely to fix the problems I saw when I tried it after salva first mentioned it here. I didn't have a specific use for it at the time, and didn't spend any time trying to work out why it wasn't working.

    Maybe you could suggest that salva mention autoflush in the POD. (Also, there are a couple of missing parens in the synopsis code that do not inspire confidence.)


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.