Printf is not working in C signal handler
In short: you cannot safely use printf
within a signal handler.
There's a list of authorized functions in signal handler's man page. There is not fprintf
in it.
That's because this function is not reentrant, mainly because it can use malloc
and free
.
See this post for a detailed explanation.
You may need to fflush stderr to get the message to write before the program exits.