I write a client program based on posix sockets. The program creates multiple threads and is going to lock the server. But during debug in gdb time the program gives an info
The process received a SIGPIPE
. The default behaviour for this signal is to end the process.
A SIGPIPE
is sent to a process if it tried to write to a socket that had been shutdown for writing or isn't connected (anymore).
To avoid that the program ends in this case, you could either
make the process ignore SIGPIPE
#include
int main(void)
{
sigaction(SIGPIPE, &(struct sigaction){SIG_IGN}, NULL);
...
or
install an explicit handler for SIGPIPE
(typically doing nothing):
#include
void sigpipe_handler(int unused)
{
}
int main(void)
{
sigaction(SIGPIPE, &(struct sigaction){sigpipe_handler}, NULL);
...
In both cases send*()
/write()
would return -1
and set errno
to EPIPE
.