In C++ when interrupted with ctrl-c call a function with arguments (other than signal number) before dying
问题 I want to write a few extra lines to a file when interrupted with ctrl-c before the program dies. However the location of the file is not hard coded so I need something more than normal interrupt handling as explained here. What is the best way to do this? Motivation: I'm doing time dependent finite element simulations. Sometimes I forget or mis-estimate a reasonable tmax and the simulation would take a very long time to complete, so I interrupt it with ctrl-c. However I still want to use the