How to use a signal handler?


#1

Hi,

With Legato 14.7:

I tried to intercept SIGPIPE using a signal handler. But it seems that the signal handler is never called: the process crashes, while the trace message that should be displayed by my handler does not appear on the console. Yes, I checked that I call le_sig_SetEventHandler(SIGPIPE, mySigHandler) :smiley:


#2

Workaround: I tell the OS to let my process ignore the signal, with a call to signal(SIGPIPE, SIG_IGN).


#3

Hi, Pascal.

For now, at least, you need to block the signal in your start-up code. Otherwise, the default signal action will take effect (in this case, terminating your process) and your handler will not be called.

It looks like there is an error in the documentation for the signal API. It says that the signal will be automatically blocked for you, but that has not been implemented yet. I have logged a ticket for that in our defect tracking system.

Sorry, and thanks! :slight_smile:

–Jen