Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Problems forking and redirecting STDOUT with Win32

by secret (Beadle)
on Dec 07, 2005 at 11:36 UTC ( #514886=note: print w/replies, xml ) Need Help??

in reply to Problems forking and redirecting STDOUT with Win32

Here is what Dave Roth says in his book "Win 32 perl programming" (new riders, ) :

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.

secret .

  • Comment on Re: Problems forking and redirecting STDOUT with Win32

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://514886]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (2)
As of 2020-02-21 17:03 GMT
Find Nodes?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?

    Results (96 votes). Check out past polls.