Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Detect whether a writeable filehandle has closed?

by Fletch (Chancellor)
on Jan 13, 2021 at 20:10 UTC ( #11126866=note: print w/replies, xml ) Need Help??


in reply to Re: Detect whether a writeable filehandle has closed?
in thread Detect whether a writeable filehandle has closed?

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.

Replies are listed 'Best First'.
Re^3: Detect whether a writeable filehandle has closed?
by GrandFather (Saint) on Jan 13, 2021 at 20:54 UTC

    With the implication that only the last write failed before the SIGPIPE so caching, or being able to regenerate, the written data may provide jdporter the recovery information he needs.

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11126866]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2021-04-12 18:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?