问题

调用了signal(SIGPIPE, SIG_IGN)仍然出现Program received signal SIGPIPE, Broken pipe.

解答

GDB调试网络程序时,会遇到SIGPIPE信息,默认GDB会把程序停下来,即使程序使用signal(SIGPIPE, SIG_IGN);来忽略信号。
在gdb模式下运行下面的命令)
handle SIGPIPE nostop print

(gdb) handle SIGPIPE nostop print
Signal        Stop      Print   Pass to program Description
SIGPIPE       No        Yes     Yes             Broken pipe

如果连信息提示都不想看见,可以这样设置:
handle SIGPIPE nostop noprint