amnh / PCG

𝙋𝙝𝙮𝙡𝙤𝙜𝙚𝙣𝙚𝙩𝙞𝙘 𝘾𝙤𝙢𝙥𝙤𝙣𝙚𝙣𝙩 𝙂𝙧𝙖𝙥𝙝 ⸺ Haskell program and libraries for general phylogenetic graph search
28 stars 1 forks source link

Add exit clean up #157

Closed Boarders closed 3 years ago

Boarders commented 4 years ago

Using the bracket function from here we can add the ability to clean up after an operation. If my understanding is correct when the GHC runtime system receives a SIGINT (e.g. if the user hits C-c) this cleanup action will be run.

In discussions with @recursion-ninja we decided on where this should be added so that we have an interrupt handler for the various different evaluate commands. Our idea was roughly that if, for instance, you have done a build command (which should probably be added as a global settings flag) then we save the work. If you are in the middle of reporting output then that finishes (unless the user absolutely does want to stop the program). This would also fit nicely into any more interactive top level we might add in the future.

recursion-ninja commented 3 years ago

This should be fairly trivial to implement in main using the modules Control.Concurrent.MVar from base and System.Posix.Signals from the unix package along with the technique described here.

recursion-ninja commented 3 years ago

This functionality has been implemented using the technique described above. See 3a1b6bdde273ed4dc09717623986e1144b006904.