Skip to content

[External] Re: Background R session on Unix and SIGINT

3 messages · Gábor Csárdi, Simon Urbanek

#
Unfortunately --interactive also makes the session interactive(),
which is bad for me, as it is a background session.

In general, I don't want the interactive behavior, but was wondering
if I could send as SIGINT to try to interrupt the computation of the
background process, and if that does not work, then I would send a
SIGKILL and start up another process. It all works nicely, except for
this glitch, but I think I can work around it.

Thanks,
Gabor
On Tue, Apr 30, 2019 at 10:55 PM Tierney, Luke <luke-tierney at uiowa.edu> wrote:
#
Gabor,

I think you're talking about two independent things. You can interrupt the computation, no question about that. It's just that if you send an interrupt while you're *not* doing any computations, it will be signaled but not raised until the interrupts are checked since there is no one to check it. This goes back to my original response - the interactive REPL calls R_CheckUserInterrupt(), but the straight stdin-prcessing doesn't (since it's expected to be a script, not interactive prompt). If you just want to clear interrupts before next processing you can either just run R_CheckUserInterrupt() explicitly, or on R side do anything that does that, e.g. to take your example "tryCatch(Sys.sleep(0), interrupt = function(e) e)" will clear it.

Cheers,
Simon
#
On Wed, May 1, 2019 at 4:20 PM Simon Urbanek
<simon.urbanek at r-project.org> wrote:
Right. That's what I suspected originally, so thank you both for
confirming it. The difficulty is, when I interrupt the computation
that's a race condition, because in the master process I have no idea
knowing whether the computation will be finished just before the
SIGINT arrives.
Yes, that's exactly what I am doing. Thanks again!

Gabor

[...]