Checking my copy of Stevens APUE my reading (and vague recollections of actual behavior) confirms this; you're not going to get SIGPIPE until you actually write to the fd the child's closed. The SIGCHLD should be the first sign you get.
use IPC::Run qw( start pump );
use Log::Log4perl qw( :easy );
Log::Log4perl->easy_init($DEBUG);
$SIG{$_} = eval qq{sub{INFO qq{Got $_}; 1}} for qw(CHLD PIPE);
INFO q{Starting};
my $in=q{};
my $chld = start(["bash","-c","sleep 5"],q{<},\$in);
## This will get CLHD and sleep will exit early
INFO q{Sleeping};
my $r=sleep(10);
WARN( qq{$r, $!} );
## This will trigger PIPE
$in .= qq{FOO};
pump $chld;
## This won't be reached.
INFO q{Done}
__END__
2021/01/13 15:07:42 Starting
2021/01/13 15:07:42 Sleeping
2021/01/13 15:07:47 Got CHLD
2021/01/13 15:07:47 5, Interrupted system call
2021/01/13 15:07:47 Got PIPE
ack Broken pipe: write( 6, 'FOO' ) at ....
The cake is a lie.
The cake is a lie.
The cake is a lie.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|