Now that's quite a bit different and seems to make more sense. I am now able to get the output I desire but there appears to be some random characters that are printed with the first line. I assume that it'll wait for the process to complete before the shutdown call is made? Or is waitpid needed?

Also, I was checking $fh against $out and $err before (see OP), I don't really seem to have that option now. What can I do to compensate or should I not bother?

sub sys { my $self = shift; my $app = shift; more(); TRACE "sys > $app @_"; my($pid, $sock) = Win32::Socketpair::winopen2_5($app, @_) or LOGDIE "f +ailed to open $app: @_"; shutdown $sock, 1; my ($sel, $buf); $sel = new IO::Select($sock); SYSLOOP: while(my @ready = $sel->can_read) { foreach my $fh (@ready) { my $line = <$fh>; if(not defined $line) { $sel->remove($fh); next; } $buf .= $line; } } waitpid($pid, 0); close $sock; less(); return $buf; }

In reply to Re^4: Open3 and IO:Select on Win32 by Elegant
in thread Open3 and IO:Select on Win32 by Elegant

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.