Because that's how it works. Signals are only raised when something abnormal happens.
If you want to run something when the program exits normally, try using atexit()
or on_exit()
.
Question
I write a library, register signal handler in function that application always called. I register following signals:
All signal handlers point to same function just like that:
signal(SIGQUIT,signal_handler);
signal(SIGINT,signal_handler);
signal(SIGKILL,signal_handler);
....
When I run the application, and exited NORMALLY, there aren't any signals raised at all.
But if I break it with <ctrl-c>
, SIGINT
will raised and my signal handler is triggered,too.
Why aren't any signals raised when the application exited normally?
La solution
Because that's how it works. Signals are only raised when something abnormal happens.
If you want to run something when the program exits normally, try using atexit()
or on_exit()
.