PDA

View Full Version : Broken Sigpipe crashing in QT event loop on OS X



willjones
9th April 2012, 09:10
I'm working on a cross-platform app. It works fine for the most part on Windows and Linux, but on OS X, I am getting crashes due to SIGPIPE Broken Pipe.

The source of this crash is inside of the event loop, and the last place in my code the debugger can show me is where I call exec().

I have already tried disabling the SIGPIPE with a call to
signal(SIGPIPE, SIG_IGN) but that doesn't seem to be working.

While my code does use networking, this isn't the way I'd expect a SIGPIPE problem with sockets to manifest, in the QT event loop.

Does anyone have any idea why this might be happening, and what I could do to fix it?

darksnake
24th April 2013, 15:25
I'm working on a cross-platform app. It works fine for the most part on Windows and Linux, but on OS X, I am getting crashes due to SIGPIPE Broken Pipe.

The source of this crash is inside of the event loop, and the last place in my code the debugger can show me is where I call exec().

I have already tried disabling the SIGPIPE with a call to
signal(SIGPIPE, SIG_IGN) but that doesn't seem to be working.

While my code does use networking, this isn't the way I'd expect a SIGPIPE problem with sockets to manifest, in the QT event loop.

Does anyone have any idea why this might be happening, and what I could do to fix it?

In source code, the SIGPIPE handler must be explicitness set to SIG_INT.
see http://stackoverflow.com/questions/7774569/using-signals-and-sigpipe
In Qt Creator, in "Preferences" -> "Debugger" -> in tab "GDB", section "Additional Startup Commands" -> next command must be typed: handle SIGPIPE nostop noprint pass
(http://ahlamnote.blogspot.ro/2006/12/gdb-ignore-sigpipe.html)
gdb stops at SIGPIPE
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 folloing command in gdb:
handle SIGPIPE nostop noprint pass