Pathologically Eclectic Rubbish Lister | |
PerlMonks |
question on getting SIGPIPE in closeby perl-diddler (Chaplain) |
on Apr 27, 2020 at 23:56 UTC ( [id://11116138]=perlquestion: print w/replies, xml ) | Need Help?? |
perl-diddler has asked for the wisdom of the Perl Monks concerning the following question:
I have some code that spawns off a child to do some work. Parent + child communicate over a pipe. I set both parts of the pipe for *unbuffered* I/O. Include snippets of code to show code for what I describe.
When parent writes last message to child I setup a pipe handler to trap any pipe sigs: With the next thing happening being a close on the pipe. The close doesn't have a SIG catcher, since there should be no SIGPIPE that would come from trying i/o on a closed pipe.
This works on linux, but on windows, I get a PIPE error in the close routine: The child is closed in the main program @ln 2576, but I see an error, at the last line in 'P' as it is exiting, which isn't far from where I would expect it if I didn't have the SIG{PIPE} handler wrapping that call. I.e. parent tells child it is done and to go away, so it does, but that should happen in the print wrapped in the PIPE handler. So question is this -- would you think this is a bug in the windows implementation given it works in linux -- and would you expect any PIPE errors in write (P) to be trapped by the sig handler? FWIW, the line where this is dumped is where unsee_ret: could be a do block: but isn't because it's done in more than one place. __P_seen is an internal hash of already seen refs in a call so P doesn't try to re-expand an already expanded ref. Only showed detail to show that it really was at the point of exit of P where I might get some auto-close behaviors.
Repeating my question in a different way: since the print call is wrapped in a PIPE handler, shouldn't the error have been seen in the pipe handler, where the code tries to turn it into an ignorable error, but instead I get a 'WARNING'. I'm pretty sure I'll just chase down a work-around -- but isn't that a correct way to do things? Perl version is Cygwin-perl 5.26.3. This isn't a time-sensitive issue, I was just playing around w/a prog I thought might be nice to have working on windows and working through the kinks...
Back to
Seekers of Perl Wisdom
|
|