Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: IO:Socket::INET: Strategies against death of child processes on broken pipe

by Corion (Patriarch)
on Oct 13, 2016 at 11:22 UTC ( [id://1173926]=note: print w/replies, xml ) Need Help??


in reply to Re^2: IO:Socket::INET: Strategies against death of child processes on broken pipe
in thread IO:Socket::INET: Strategies against death of child processes on broken pipe

I would expect the dissociated child to be immune from signals sent to the parent process.

But given your code, I cannot see or reproduce where a Broken Pipe signal or error happens in either the child part or the parent part of the client program. Maybe somewhere in your real client program you do not properly catch a write failure to the parent process.

While looking through your code, I found the overall interaction very confusing. The current image I have from your process setup is the following:

server.pl <--- TCP :7777 --> client.pl <--- readpipe() + ---> client.pl forked child + forking parent $reader + $writer

Maybe my impression of this is wrong; if so, please correct it.

From that image, I think your real problem is not in the interaction between client.pl and server.pl, but in the interaction between the forked child of client.pl and the parent client.pl, which communicate by a pipe. And one of the sides seems to close the pipe prematurely such that the other end tries to interact with its end of the pipe and then receives a signal for trying that. But that interpretation is not really exercised by your test scenario which is "stopping the server at random". Maybe you can work on your client script or check better where the interactions with the pipe happen and put more diagnostics there to make it clearer (at least to you) where the signal actually is received and what might cause it.

Note that I've tried your scripts on some random version of Linux only. Signals behave differently on different operating systems and vastly differ in the interaction with fork(), especially on Windows. So it might be of use if you state your type and version of OS.

Your current scripts do not use strict, which makes it hard for me to judge whether the variables you use are actually the variables you intend to use. For example, the forked child seems to make a fresh connection to the server on every new line it wants to write to the server, and I'm not sure if that is intended or an artifact of weirdly scoped variables. If you could provide a version of your programs that has the variables properly and explicitly scoped so that it compiles and runs under use strict;, that would help me to help you better.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2024-04-18 14:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found