This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Handle fcntl(F_GETPIPE_SZ) failure in t/io/eintr.t
authorDagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Fri, 20 Mar 2015 17:49:12 +0000 (17:49 +0000)
committerTony Cook <tony@develop-help.com>
Tue, 2 Jun 2015 00:16:40 +0000 (10:16 +1000)
Even if the F_GETPIPE_SZ constant is defined, the fcntl() call can
fail (e.g. with EINVAL), so fall back to the default in that case.

t/io/eintr.t

index ca15232..1a81cdf 100644 (file)
@@ -102,10 +102,10 @@ ok(close($in), 'read/die: close status');
 # consistently failing. At exactly 0x100000 it started passing
 # again. Now we're asking the kernel what the pipe buffer is, and if
 # that fails, hoping this number is bigger than any pipe buffer.
-my $surely_this_arbitrary_number_is_fine = eval {
+my $surely_this_arbitrary_number_is_fine = (eval {
     use Fcntl qw(F_GETPIPE_SZ);
-    fcntl($out, F_GETPIPE_SZ, 0) + 1;
-} || 0x100000;
+    fcntl($out, F_GETPIPE_SZ, 0);
+} || 0xfffff) + 1;
 
 # close during print