Simplify tests for fork() capabilities
authorSteve Hay <SteveHay@planit.com>
Wed, 5 Apr 2006 10:35:58 +0000 (10:35 +0000)
committerSteve Hay <SteveHay@planit.com>
Wed, 5 Apr 2006 10:35:58 +0000 (10:35 +0000)
Jarkko pointed out that change #27710 was causing some
black smoke so makes the tests for fork() simpler, as
per lib\Test\Simple\t\fork.t for now. (Ideally we want
a $Config{d_pseudofork}, as suggested by Andy Dougherty,
but that'll have to wait until I get some more tuits.)
p4raw-link: @27710 on //depot/perl: 2f78ce11bc4a9355ade5d20a0825b10fbb177169

p4raw-id: //depot/perl@27718

ext/IO/t/io_multihomed.t
ext/IO/t/io_pipe.t
ext/IO/t/io_sock.t

index d9355cf..3560d7b 100644 (file)
@@ -10,6 +10,11 @@ BEGIN {
 use Config;
 
 BEGIN {
+    my $can_fork = $Config{d_fork} ||
+                   (($^O eq 'MSWin32' || $^O eq 'NetWare') and
+                    $Config{useithreads} and 
+                    $Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/
+                   );
     my $reason;
     if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bSocket\b/) {
        $reason = 'Socket extension unavailable';
@@ -17,15 +22,8 @@ BEGIN {
     elsif ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bIO\b/) {
        $reason = 'IO extension unavailable';
     }
-    elsif (
-        ! eval {
-            my $pid= fork();
-            ! defined($pid) and die "Fork failed!";
-            ! $pid and exit;
-            defined waitpid($pid, 0);
-        }
-    ) {
-        $reason = "no fork: $@";
+    elsif (!$can_fork) {
+        $reason = 'no fork';
     }
     if ($reason) {
        print "1..0 # Skip: $reason\n";
index 857d3d0..f4519a2 100755 (executable)
@@ -16,19 +16,17 @@ BEGIN {
 use Config;
 
 BEGIN {
+    my $can_fork = $Config{d_fork} ||
+                   (($^O eq 'MSWin32' || $^O eq 'NetWare') and
+                    $Config{useithreads} and 
+                    $Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/
+                   );
     my $reason;
     if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bIO\b/) {
        $reason = 'IO extension unavailable';
     }
-    elsif (
-        ! eval {
-            my $pid= fork();
-            ! defined($pid) and die "Fork failed!";
-            ! $pid and exit;
-            defined waitpid($pid, 0);
-        }
-    ) {
-        $reason = "no fork: $@";
+    elsif (!$can_fork) {
+        $reason = 'no fork';
     }
     elsif ($^O eq 'MSWin32' && !$ENV{TEST_IO_PIPE}) {
        $reason = 'Win32 testing environment not set';
index b743bf0..24d6818 100755 (executable)
@@ -10,6 +10,11 @@ BEGIN {
 use Config;
 
 BEGIN {
+    my $can_fork = $Config{d_fork} ||
+                   (($^O eq 'MSWin32' || $^O eq 'NetWare') and
+                    $Config{useithreads} and 
+                    $Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/
+                   );
     my $reason;
     if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bSocket\b/) {
        $reason = 'Socket extension unavailable';
@@ -17,15 +22,8 @@ BEGIN {
     elsif ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bIO\b/) {
        $reason = 'IO extension unavailable';
     }
-    elsif (
-        ! eval {
-            my $pid= fork();
-            ! defined($pid) and die "Fork failed!";
-            ! $pid and exit;
-            defined waitpid($pid, 0);
-        }
-    ) {
-        $reason = "no fork: $@";
+    elsif (!$can_fork) {
+        $reason = 'no fork';
     }
     if ($reason) {
        print "1..0 # Skip: $reason\n";