Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Windows filehandles and fork

by Koosemose (Pilgrim)
on Apr 09, 2004 at 07:26 UTC ( [id://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?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2024-04-23 17:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found