I would like to assign some code that will be run when R is killed, for instance, save(list=ls(),file="dump.RData")
. I thought this would be by trapping signals, e.g. SIGTERM
, as referred to in this post, but there's nothing about signals from the shell in ?conditions
.
?conditions
does mention user interrupts; you can e.g. catch a Ctrl-C
with withCallingHandlers( Sys.sleep(10), interrupt=function (e){cat("I saw that.\n")} )
, but this doesn't catch SIGTERM.
How can I do this?