Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

(tye)Re: fork and open3 on Win32

by tye (Sage)
on Apr 28, 2001 at 10:11 UTC ( [id://76356]=note: print w/replies, xml ) Need Help??


in reply to fork and open3 on Win32

fork in Win32 Perl is just simulated using threads and separate interpreter instances. So, no, after fork you still only have one process so, in particular, all file handles are shared.

Instead of using fork, you need to create a new process. Something like:

#!/usr/bin/perl -w my $CMD = 'cat'; use IO::Handle; use IPC::Open3 qw( open3 ); use strict; my $pid; if( $^W =~ /mswin32/i ) { unless( @ARGV && $ARGV[0] =~ /^-child$/i ) { $pid= system( 1, qq("$^X" "$0" -child) ) or die "system() failed: $!\n"; } else { shift @ARGV; $pid= 0; } } else { $pid = fork(); if ( !defined($pid) ) { die( "$$: Fork failed: $!\n" ); } } # parent if ( $pid ) { #...
(not fully tested)

        - tye (but my friends call me "Tye")

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-19 18:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found