dave_usa has asked for the wisdom of the Perl Monks concerning the following question:
With Perl 5.6 it works correctly. Both hellos are printed to the screen and you will also see the output of ipconfig to be printed to the screen. But note, that the ipconfig output goes to the file first and then it is read from the file being printed to STDOUT.#!perl -w my $fn = 'fork_test.txt'; my $pid; if ($pid = fork) { print "Hello from ithread 1\n"; open(STDOUT,'>',$fn); system('ipconfig'); close STDOUT; waitpid($pid,0); } else { die 'Couldn\'t fork!' unless defined $pid; open(READ,'<',$fn); print "Hello from ithread 2\n"; my $l; do { undef $l; my $i = 0; while(!defined($l)) { my $slp = int(($i++ + 9) / 10); sleep($slp); $l = <READ>; }; print $l; } until($l =~ /Gateway/); close READ; }
update (broquaint): changed <small><pre> to <code>
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: fork on Windows (Perl 5.8)
by BrowserUk (Patriarch) on Jun 30, 2003 at 19:14 UTC | |
|
Re: fork on Windows (Perl 5.8)
by Thelonius (Priest) on Jun 30, 2003 at 17:23 UTC | |
by dave_usa (Novice) on Jun 30, 2003 at 19:01 UTC | |
by Thelonius (Priest) on Jun 30, 2003 at 22:35 UTC | |
|
Re: fork on Windows (Perl 5.8)
by fglock (Vicar) on Jun 30, 2003 at 17:13 UTC |