The job of my Unix executable file is to perform a long computation, and I added a interrupt/resume functionality to it as explained below.
At regular intervals, the program writes all relevant data found so far in a checkpoint file, which can then be used as a starting point for a "resume" operation.
To interrupt the program, I use Ctrl+C.
The only problem with this methodology is that, if the interruption occurs
when the program is writing into the file, I am left with a useless half written file.
The only fix I could find so far is as follows:
- make the program
- write into two files, so that at restart time one of them will be readable.
Is there a cleaner, better way to create an "interruptable" Unix executable ?