SIGPIPE, broken pipe signal...


I’m maintaining a realtime program, which uses FIFO extensively.
A couple of months ago, we upgraded our QNX and sped up the program as well by changing the timer resolution (we had to do these upgrading because of the project requirement), which was very successful.

But, sometimes the program stops (or terminates) abnormally. We have to restart the program when this happens, which is really annoying. (Whole job takes about 2 hours, and the bug pops out occasionally, like after an hour, or just before the end of the job.) So, after a couple of months of critial project period, I, now, want to fix this problem.

So, I ran it in the gdb and got the message that, “SIGPIPE, broen pipe signal”.

How can I catch this signal (like using exception handling mechanism), and recover the pipe?


==> Sorry!!! The problem is not SIGPIPE. See the first reply for the real problem… Thanks.

My colleague found that the receiver gets corrupted character. (Programs communicate using simple characters.) For example, the sender sends ‘m’ or ‘f’, etc, but the receiver receives ‘A’ or ‘B’ something like that and exits (because it is the default action when it gets illegal character). Then there is no receiver, therefore, sender cannot write into the FIFO, which raises SIGPIPE error.

Do you have any idea how to solve this problem? Is this problem usual in QNX world?

I think that SIGPIPE error occur, when receiver have no time to reading data, and FIFO is overflow. Try to decrement FIFO buffer and run you program again, if time to rise SIGPIPE error decrement to, then problem in this.

You can catch the signal using signal() or sigaction() and do an action.
You can also choose to ignore the signal (eg: signal(SIGPIPE, SIG_IGN)) and then process the error on the file descriptor after you try to write on it.
I prefer ignoring the signal and handle the error on the descriptor.
Yes, this is usual.

I found that once the pipe is corrupted, then it cannot be recovered or flushed. (at least, I couldn’t find a way to do this.)

So, I simply disconnected the pipe from both side and remade the pipe connection again. And it works.