Skip to content

Detecting user interrupts in R_tryEval

2 messages · Jeroen Ooms, William Dunlap

#
Is there any way to distinguish between an error and a user
interruption in R_tryEval? In both cases the ErrorOccurred argument is
set to 1. For my application I need a different action in case of a
SIGINT.
R_ToplevelExec, which returns TRUE if fun returns normally, FALSE if
it results in a jump to top level. However both an error and SIGINT
result in a jump. Is there an alternative method, or some method of
finding out which is the two happened after calling R_tryEval?

One thing I tried is see if R_curErrorBuf() is empty. However this is
unreliable because in the case of an interrupt, the error buffer
sometimes contains some old error message.
#
In R code tryCatch can detect the difference.  Hit control-C (on Unixen) or
Escape
(on Windows) to interrupt the long-running for loop and see that the
interrupt clause
gets called:
interrupt=function(e)e)
^C> dput(z)
structure(list(), class = c("interrupt", "condition"))



Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Thu, Jul 7, 2016 at 10:18 AM, Jeroen Ooms <jeroen.ooms at stat.ucla.edu>
wrote: