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.
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |