Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^4: question on getting SIGPIPE in close

by perl-diddler (Chaplain)
on May 01, 2020 at 02:47 UTC ( [id://11116295]=note: print w/replies, xml ) Need Help??


in reply to Re^3: question on getting SIGPIPE in close
in thread question on getting SIGPIPE in close

Does it work 'where'? I had it bracketing the write call and added bracketing for the close statement:
sub close_child_io () { Debug "SigCHLD: close iopair[1]"; local * pipe_catch = sub ($) { Debug "Child already closed"; $iopair[1] = $iopair[0] = undef; }; my $tmp = $PathTree::iopair[1]; $PathTree::iopair[1] = undef; $SIG{PIPE}=\&pipe_catch; close($tmp); $SIG{PIPE}='DEFAULT'; };
Only the "using-TNT-to-kill-a-fly" idea of redirecting STDERR to /dev/null before every write through perl seems to shut it up:
|2588 local * write_child = sub ($) { |2589 my $out=$_[0]; |2590 return unless $iopair[1] and ref $iopair[1] and -w $iopair +[1]; |2591 |2592 local * pipe_catch = sub ($) { Debug "Child closed"; |2593 $iopair[1] = $iopair[0] = undef; }; |2594 |2595 $SIG{PIPE}=\&pipe_catch; |2596 no warnings; |2597 open (OLDERR, ">&", \*STDERR) or die "Can't dup STDERR: $! +"; |2598 open (STDERR, ">", "/dev/null") or die "Can't redirect STD +ERR to /dev/null: $!"; |2599 select STDERR; $|=1; |2600 P $iopair[1], $out."\n" ; |2601 open(STDERR, ">&OLDERR") or die "Can't restore stderr: $!" +; |2602 $SIG{PIPE}='DEFAULT'; |2603 };

Replies are listed 'Best First'.
Re^5: question on getting SIGPIPE in close
by jcb (Parson) on May 02, 2020 at 03:21 UTC

    That sounds like perl is remembering an error from an earlier failed write and reporting it when the pipe is closed or something else entirely is going on...

    I finally searched perldiag for "unable to close filehandle" and that message indicates that the "implicit close done by an open got an error indication" so now I must ask: what is sub P?

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2024-04-23 10:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found