Hi Dirk, I have a question about your example on better handling of interrupts with Rcpp: you set the signal handler on entry into the function, but never reset it to the original value. Should that be done as part of the cleanup? What will happen when the function returns to R, whether it was interrupted or not? Davor
On 2010-12-08, at 1:02 PM, Dirk Eddelbuettel wrote:
Here is a simple example that uses a standard C interrupt handler to set a standard C++ exception to abort:
...
RcppExport SEXP foo(void) {
try {
signal(SIGINT, intHandler);
signal(SIGKILL, intHandler);
[...]
} catch(std::exception &ex) {
std::cerr << "In catch of std::exeception" << std::endl;
// here you insert some clenup
forward_exception_to_r(ex);
} catch(...) {
::Rf_error("c++ exception (unknown reason)");
}
return R_NilValue;
}