Here is what Dave Roth says in his book "Win 32 perl programming" (new riders, http://books.perl.org/book/126 ) :

Process can inherit Win32 handles. Notice that i am specifying Win32 handles, not Perl file handles; this is very important. (...) If the new process you create is a Perl script, however, don't expect to be able to access those opened sockets and files you inherited. This is because a Perl file handle differs from a Win32 handle. You see, Perl creates a file handle by asking the C language's runtime library to open the file. The C library, in turn, asks the operating system to open it. The Win32 API will return a handle (...) , and the C library will store the handle into some data structure it creates. A pointer to this structure will be returned to Perl, which puts this pointer into yet another structure. Perl will then associate a Perl file handle (...) with this structure. Because a new process does not have access to memory in other process, any inherited memory pointer won't point to the original memory structure.

This means (as he concludes soon after) that only the Win32 file handle is inherited and not the Perl file handle.

He suggests to use Win32::AdminMisc::GetStdHandle but the book is a bit outdated and my option is to use Win32::Job which allows to pass handles around.

HTH,
secret .


In reply to Re: Problems forking and redirecting STDOUT with Win32 by secret
in thread Problems forking and redirecting STDOUT with Win32 by xdg

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.