今天在gdb调试时,发现总是出现Program received signal SIGPIPE, Broken pipe,搜索了网上的资料,发现是在调试时,接收到了SIGPIPE这个signal信号导致调试被中断。
By default, gdb captures SIGPIPE of a process and pauses it. However, some program ignores SIGPIPE. So, the default behavour of gdb is not desired when debugging those program. To avoid gdb stopping in SIGPIPE, use the following command in gdb.
解决方式:在gdb调试窗口中输入以下命令即可,将接收到的SIGPIPE signal忽略
handle SIGPIPE nostop noprint nopass 或 handle SIGPIPE nostop noprint pass