Skip to content

Commit 1c27c43

Browse files
committed
Avoid SIGNAL on IO error in 02_parallel.t and add test for it
1 parent 05e7891 commit 1c27c43

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

t/02_parallel.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ subtest batch => sub {
7171
set_pipes => 1
7272
);
7373
$c->start();
74-
is $c->last->getline, "Hello world 3\n";
7574
$c->wait_stop();
75+
is $c->last->getline, "Hello world 3\n";
7676

7777
my $result;
7878
$c->add(code => sub { return 40 + 2 }, separate_err => 0, set_pipes => 0);

t/14_sig_on_io.t

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/perl
2+
3+
use Mojo::Base -strict;
4+
use Test::More;
5+
use Time::HiRes qw(sleep);
6+
use FindBin;
7+
use lib ("$FindBin::Bin/lib", "../lib", "lib");
8+
use Mojo::IOLoop::ReadWriteProcess qw(process batch);
9+
use Data::Dumper;
10+
11+
my $sleepduration = 0;
12+
13+
subtest "Signal on IO" => sub {
14+
my @stack;
15+
16+
my $p1 = process(sub { sleep 2; print "Hello world\n" });
17+
for my $i (1 .. 10) {
18+
push (@stack, process(sub { sleep 0.2 * $i; print "Bye Bye"}))
19+
}
20+
my $c = batch @stack;
21+
22+
$p1->start;
23+
$c->start();
24+
is ($p1->getline(), "Hello world\n", "P1 can read with signals received!");
25+
is (!!$!{EINTR}, 1, "EINTR is set");
26+
};
27+
28+
done_testing;

0 commit comments

Comments
 (0)