[Rd] Capturing signals from within external libs

From: Jeffrey Ryan <jeff.a.ryan_at_gmail.com>
Date: Tue, 22 May 2012 15:31:07 -0500

I have a continuous loop running in an external library that I am calling from C (R API). This loop is processing events in real time with the possibility of significant lag between events.

When processing an event, I can make use of R_CheckUserInterrupt, but while the external library code is waiting on a new event, I don't have an opportunity to call this - my entry points are only on events.

I can capture a SIGINT by redefining signal(SIGINT, myhandler) before calling the lib, but I am somewhat at a loss in terms of what I can do within the handler that would let me pass control back to R.

void myhandler (int s) {
  error("interrupt caught!");

Works, but I am sure it isn't supposed to. In fact I know it is wrong, since after interrupting once SIGINTs are subsequently ignored, even if I reset the signal to the original one (as returned by the first call to signal).

Currently I can exit(1) of course, but that is tragically bad form IMO, though will work in my situation.

In short, what is the proper way to handle SIGINT in external code that is called from R, that allows R to handle the signal. Thoughts or suggestions appreciated.


R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 22 May 2012 - 20:34:00 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 22 May 2012 - 22:11:35 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive