write/send to socket crashes process - How come?

write/send to socket crashes process - How come?

Post by Bjor » Fri, 26 Feb 1999 04:00:00



When I write/send to a (TCP/IP) socket the writing thread (and process)
crashes if the receiving system crashes. So if the receiving system
crashes,
receiving sockets are not closed correctly (I think). But this may not
be a reason
for the sender to crash.

The process crashes when it sends to a socket that the sender 'sees'
still as correct
but has a corresponding receive socket that is not correct anymore due
to a crash of
the receiving process. After the crash of the receiver, it is always the
second message
(write) to the socket that lets sender crash.

Is there a solution for the problem? I think the send() or write()
function should return
with -1 instead of letting the system crash.

Thanks in advance,

Bjorn Vrijkorte

 
 
 

write/send to socket crashes process - How come?

Post by Bjor » Fri, 26 Feb 1999 04:00:00


The problem is solved:

Your process is probably getting SIGPIPE because it is trying to write
to a socket with no peer endpoint.  If you don't catch or ignore
SIGPIPE, it will kill your process.

Catch or ignore SIGPIPE.  Then you'll get your -1 return code and
EPIPE in errno.

Regards,
-christian

And that's it!!!  So simple :(
Again, Thank you...

 
 
 

write/send to socket crashes process - How come?

Post by Quanyi Su » Fri, 05 Mar 1999 04:00:00



: When I write/send to a (TCP/IP) socket the writing thread (and process)
: crashes if the receiving system crashes. So if the receiving system
: crashes,
: receiving sockets are not closed correctly (I think). But this may not
: be a reason
: for the sender to crash.

: The process crashes when it sends to a socket that the sender 'sees'
: still as correct
: but has a corresponding receive socket that is not correct anymore due
: to a crash of
: the receiving process. After the crash of the receiver, it is always the
: second message
: (write) to the socket that lets sender crash.

: Is there a solution for the problem? I think the send() or write()
: function should return
: with -1 instead of letting the system crash.

: Thanks in advance,

: Bjorn Vrijkorte

Your socket is TCP/IP sockstream. Your program should catch SIGPIPE,
because it is generated when the receiving process dies. By default,
this signal will kill you.
Quanyi Sun