shijumic has asked for the wisdom of the Perl Monks concerning the following question:
if ($^O eq 'MSWin') { print("\nrunning directly from Windows is not supported -- Install + Cygwin\n\n"); exit(1); } my ($IO_FLAGS, $OS_MSWIN); BEGIN { ($IO_FLAGS, $OS_MSWIN) = (0, FALSE); # set any linux default values my $isWindows = FALSE; my $ioFlags = 0x00005421; if ($^O =~ m/win/i) { # change to win32 values $isWindows = TRUE; $ioFlags = 0x8004667e; } $processes=2; my $pid = fork(); for (my $i = 1; $i <= $processes; $i++) { my($child,$parent); socketpair($child,$parent,AF_UNIX,SOCK_STREAM,PF_UNSPEC) or die 'socketpair creation failure: '.$!; my $pid; if ($pid = fork) { close($parent); my @ary=(1); # non-blocking IO, compare to blocking "my @ary=(0);" my $val=pack("L",@ary); ioctl($child, $IO_FLAGS, $val); # we now have another child! we'll poll these later push @children, [ $child, $pid ]; push @pids, $pid; } else { debug 'child starting'; close($child); # kick off the child process childProcess($parent); close($parent); exit(); } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: fork and socketpair
by Anonymous Monk on Apr 29, 2009 at 18:34 UTC | |
|
Re: fork and socketpair
by dk (Chaplain) on May 04, 2009 at 09:06 UTC | |
by Anonymous Monk on May 04, 2009 at 09:08 UTC |