Is there anyway to capture a SIGINT or SIGTERM from the shell in R so that I can try to execute some graceful exit code?
So far, I haven't found anything in my search.
Is there anyway to capture a SIGINT or SIGTERM from the shell in R so that I can try to execute some graceful exit code?
So far, I haven't found anything in my search.
It has been a while since you asked and in the meantime someone solved this in a package:
https://github.com/atheriel/sigterm
From the README:
sigterm is an extremely simple package that provides a way to implement just these kinds of operations in response to SIGTERM: when the package is loaded, it will install a signal handler that prevents R from immediately exiting. Users can then periodically check whether a SIGTERM signal has been received and respond appropriately.