http://qs1969.pair.com?node_id=343859


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