I am working in the Linux environment, and I have a C++ program, what I want is when I cancel the program with ctrl+c I would like that the program executes a function, to close some files and print some sutff, is there any way to do this?. Thank you.
Share
signal()can be dangerous on some OSes and is deprecated on Linux in favor ofsigaction(). ‘signal versus sigaction’Here’s an example that I ran across recently (‘Tap the interrupt signal’) and modified as I was playing around with it.