Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Windows filehandles and fork

by Koosemose (Pilgrim)
on Apr 09, 2004 at 07:26 UTC ( #343859=note: print w/replies, xml ) Need Help??

in reply to Windows filehandles and fork

Ok, after a bit more research I would have to agree with esskar, apparently win32 children don't get their own STDOUT due to being implemented as threads. It would seem that the simplest solution would be to open a brand new filehandle in the child and just select it, as follows (which of course could be done in the $fh method, but I'm more comfortable with FH):

if ($pid=fork() ) { select(undef,undef,undef,.1); print "parent\n"; } else { open (CHLDOUT, ">test.txt"); select CHLDOUT; system("echo child"); }

Now that I know better what's going on I'm pretty confident that this version will not only work as expected, but will actually work due to being done proper, instead of due to accident :)

Just Another Perl Alchemist

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2023-05-29 18:17 GMT
Find Nodes?
    Voting Booth?

    No recent polls found