develooper Front page | perl.perl5.porters | Postings from July 2013

[perl #119097] print returning EINTR in 5.14

Thread Next
From:
Victor Efimov
Date:
July 31, 2013 19:31
Subject:
[perl #119097] print returning EINTR in 5.14
Message ID:
rt-3.6.HEAD-2552-1375299057-574.119097-75-0@perl.org
# New Ticket Created by  Victor Efimov 
# Please include the string:  [perl #119097]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=119097 >


Test case:

#!/usr/bin/env perl

use strict;
use warnings;
use utf8;
use Test::More tests => 20;
use Time::HiRes qw/usleep ualarm/;
use IO::Pipe;


local $SIG{ALRM} = sub { print STDERR "ALRM $$\n" };
my $sample = 'abxhrtf6';
my $full_sample = 'abxhrtf6' x (8192-7);
my $sample_l = length $full_sample;

my $ppid = $$;
my $fh = new IO::Pipe;

if (my $pid = fork()) {
    my $child_exited = 0;
    $fh->reader();
    $fh->autoflush(1);
    $fh->blocking(1);
    binmode $fh, ":perlio";

    usleep 100_000;
    for (1..10) {
        my $n = read($fh, my $x, $sample_l);
        die "EOF" unless $n;
        is $n, $sample_l, "should return right amount of data";
        ok $x eq $full_sample, "should return right data"
    }

    while(wait() != -1 ){};
} else {
    $fh->writer();
    $fh->autoflush(1);
    $fh->blocking(1);
    binmode $fh, ":perlio";

    for (1..10) {
        ualarm(10_000);
        while ( !print($fh $full_sample) && $!{EINTR} ) { print STDERR
"print failed: [ $! ]\n" };
        ualarm(0);
    }

    exit(0);
}

1;

__END__


Works fine under all perls ( Linux ), except perl-5.14

when works fine:

1..20
ALRM 32265
ok 1 - should return right amount of data
ok 2 - should return right data
ok 3 - should return right amount of data
ok 4 - should return right data
ok 5 - should return right amount of data
ok 6 - should return right data
ok 7 - should return right amount of data
ok 8 - should return right data
ok 9 - should return right amount of data
ok 10 - should return right data
ok 11 - should return right amount of data
ok 12 - should return right data
ok 13 - should return right amount of data
ok 14 - should return right data
ok 15 - should return right amount of data
ok 16 - should return right data
ok 17 - should return right amount of data
ok 18 - should return right data
ok 19 - should return right amount of data
ok 20 - should return right data


in 5.14:

1..20
ALRM 2058
print failed: [ Interrupted system call ]
print failed: [ Interrupted system call ]
ok 1 - should return right amount of data
ok 2 - should return right data
print failed: [ Interrupted system call ]
ok 3 - should return right amount of data
ok 4 - should return right data
print failed: [ Interrupted system call ]
ok 5 - should return right amount of data
ok 6 - should return right data
print failed: [ Interrupted system call ]
ok 7 - should return right amount of data
ok 8 - should return right data
print failed: [ Interrupted system call ]
ok 9 - should return right amount of data
ok 10 - should return right data
print failed: [ Interrupted system call ]
ok 11 - should return right amount of data
ok 12 - should return right data
print failed: [ Interrupted system call ]
ok 13 - should return right amount of data
ok 14 - should return right data
print failed: [ Interrupted system call ]
ok 15 - should return right amount of data
ok 16 - should return right data
print failed: [ Interrupted system call ]
ok 17 - should return right amount of data
ok 18 - should return right data
ok 19 - should return right amount of data
ok 20 - should return right data
print failed: [ Interrupted system call ]
^C

so print returns undef + EINTR, and even if restart print operation, it
hangs, with both :perlio or :raw mode.

possible similar issue: http://www.perlmonks.org/?node_id=1026542

I wonder if this a bug, maybe a fix should be backported, or a test case
created.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About