This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Gentler theads test
authorJerry D. Hedden <jdhedden@cpan.org>
Thu, 11 Oct 2007 09:12:21 +0000 (05:12 -0400)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Thu, 11 Oct 2007 13:14:21 +0000 (13:14 +0000)
From: "Jerry D. Hedden" <jdhedden@cpan.org>
Message-ID: <1ff86f510710110612j6ecaa1d5ta1a6f2a4e3e13ed3@mail.gmail.com>

p4raw-id: //depot/perl@32099

t/op/threads.t

index 8dadfb3..8907d80 100644 (file)
@@ -148,8 +148,13 @@ EOI
 # run-time usage of newCONSTSUB (as done by the IO boot code) wasn't
 # thread-safe - got occasional coredumps or malloc corruption
 {
+    local $SIG{__WARN__} = sub {};   # Ignore any thread creation failure warnings
     my @t;
-    push @t, threads->create( sub { require IO }) for 1..100;
+    for (1..100) {
+        my $thr = threads->create( sub { require IO });
+        last if !defined($thr);      # Probably ran out of memory
+        push(@t, $thr);
+    }
     $_->join for @t;
     ok(1, '[perl #45053]');
 }