From hb at biostat.ucsf.edu  Wed Apr 13 01:22:05 2011
From: hb at biostat.ucsf.edu (Henrik Bengtsson)
Date: Tue, 12 Apr 2011 16:22:05 -0700
Subject: [Rd] Signal handling / alarm timeouts
In-Reply-To: <BANLkTim5yAHWgj9N4de19TOn1=oe0NkujA@mail.gmail.com>
References: <BANLkTim5yAHWgj9N4de19TOn1=oe0NkujA@mail.gmail.com>
Message-ID: <BANLkTinzkT_Ooa5CzWNr+PB2onmCQ2M0ug@mail.gmail.com>

On Tue, Apr 12, 2011 at 3:58 PM, Murray Stokely <murray at stokely.org> wrote:
> What are the ramifications of setting up user signal handling to allow
> the use of e.g. alarm(2) to send a SIGALRM to the R process at some
> number of seconds in the future to e.g. interrupt a routine that is
> taking too long to complete.
>
> I can't find any R language support for this (e.g. a timeout argument
> to tryCatch() would be ideal), so am wondering what kinds of problems
> are to be expected if I do this with native C code in a package.
>
> Are there other ways to accomplish timeouts for blocks of R code like this?

See R help thread 'Time out for a R Function' on 2010-12-06
[http://www.mail-archive.com/r-help at r-project.org/msg119344.html].  As
explained there, R provides setTimeLimit(), which is cross platform so
you don't have to rely on OS-specific signals.  In R.utils there is
evalWithTimeout(), which utilizes setTimeLimit().

/Henrik

>
> ? ? ? ? ? ? ? - Murray
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] Signal handling / alarm timeouts
Henrik Bengtsson