Skip to content

Commit 6d63380

Browse files
author
Jan Henning Thorsen
committed
Need to close the stream on "Bad file decriptor"
1 parent 0cc9d5d commit 6d63380

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

lib/Mojo/IOLoop/ReadWriteFork.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ sub _stdin {
375375
my $stream = Mojo::IOLoop::Stream->new($handle);
376376

377377
Scalar::Util::weaken($self);
378+
$stream->on(error => sub { $! == 9 ? shift->close : return $self->emit(error => $_[1]); });
378379
$stream->reactor($self->reactor);
379380
$stream->timeout(0);
380381
$stream->start;

t/close.t

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use Test::Memory::Cycle;
88
my $output = '';
99

1010
$run->on(close => sub { Mojo::IOLoop->stop; });
11+
$run->on(error => sub { diag "error: @_" });
1112
$run->on(read => sub { $output .= $_[1]; });
1213
$run->write("line one\nline two\n", sub { shift->close('stdin'); });
1314
$run->run(sub { print while <>; print "FORCE\n"; });
@@ -23,6 +24,7 @@ use Test::Memory::Cycle;
2324
my $output = '';
2425

2526
$run->on(close => sub { Mojo::IOLoop->stop; });
27+
$run->on(error => sub { diag "error: @_" });
2628
$run->on(read => sub { $output .= $_[1]; shift->close_gracefully('stdin'); });
2729
$run->write("line one\nline two\n");
2830
$run->run(sub { print while <>; print "GRACEFUL\n" });

0 commit comments

Comments
 (0)