Re: [Rd] sending signals to embedded R

From: Luke Tierney <luke_at_stat.uiowa.edu>
Date: Fri, 04 May 2007 18:35:20 -0500 (CDT)

On Fri, 4 May 2007, Deepayan Sarkar wrote:

> On 5/4/07, Prof Brian Ripley <ripley@stats.ox.ac.uk> wrote:
>> On Fri, 4 May 2007, Deepayan Sarkar wrote:
>>
>>> one thing I haven't been able to figure out from R-exts is how to
>>> interrupt a calculation running inside an embedded R. C code inside R
>>> calls R_CheckUserInterrupt() intermittently to check for interrupts,
>>> but how does my GUI tell R that the user wants it interrupted?
>>
>> Well, the intention is that you send an interrupt, which hardly needs to
>> be in the manual.
>
> I didn't mean to imply that it does. I'm just new to signals and
> things that should be obvious aren't.
>
> Basically kill(2) seems to be the right thing to use, but I wasn't
> sure what the PID needs to be. Turns out sending SIGINT to my GUI from
> a shell interrupts R, so raise(SIGINT) should be enough.

The tricky bit here is figuring out who does the sending. It you have a separate thread/process for the GUI and R then that is fine (though may raise other issues). If it is a single thread then you need your event processing to get an occasional look in to recognise the user action that triggers an interrupt. The Windows version handles this by having R_CheckUserInterrupt() do a limited amount of event processing (you need to be careful in GUI events have R actions associated with them). I believe the Mac version is similar though it has been a while since I looked at that. I don't believe the unix version of R_CheckUserInterrupt() does not provide hooks for installing such checking (we have talked about this off an on but I don't believe anything happened -- could be wrong there though).

If Qt allows this one option may be to have events on your nterrupt widget managed by a small thread that does nothing other than send a signal to the main thread if the widget is clicked.

Best,

luke

-- 
Luke Tierney
Chair, Statistics and Actuarial Science
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:      luke_at_stat.uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu

______________________________________________
R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri 04 May 2007 - 23:38:11 GMT

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 Sat 05 May 2007 - 13:34:05 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.