Can R interpret a SIGINT/SIGTERM and execute a process as a result?

395 views Asked by At

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.

1

There are 1 answers

0
FvD On

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.