I have written an exe that could run for hours. I want to add feature that if a user wants to terminate the program in a few minutes instead of waiting for hours, he could just press Ctrl-C and a clean-up function gets called, which cleans up heap memory and exits.
By command line arguments. The program could run infinitely. But I'd like it to listen to Ctrl-C and if user presses Ctrl-C, then clean-up is called and program exits.