The real problem here is that the InheritHandles flag on CreateProcess() relates to OS handles (of all types), not Perl filehandles or C-runtime file numbers or FILE* structs. Nothing you do to the current process Perl handles or CRT handles will have any influence upon the created process at all.

Setting the Inherit Handles flag will cause the process created to inherit access to exists OS handles of the current process. But in order for the new process to inherit redirections of it's STD_INPUT_HANDLE, STD_OUTPUT_HANDLE, or STD_ERROR_HANDLE handles, it is necessary to pass the handles that it should inherit as a part of the STARTUPINFO struct on the CreateProcess() and set the STARTF_USESTDHANDLES flag. Only then would the OS got the information required to make the appropriate redirection(s). This functionality is not visible via Win32::Process.

I did manage to get this to work from Perl using Win32::API a couple of years ago, but that was before I upgraded my 0.41 installation. Since then, trying pretty much anything with Win32::API breaks :(

That's problem when people with no real interest in the OS start messing with things just to try and make it so that other people with no real interest in the OS can avoid using it.


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.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to Re^3: Win32::Process handle inheritance (don't use 'local' on file handles) by BrowserUk
in thread Win32::Process handle inheritance by shura

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.