From c@@rd|@g@bor @end|ng |rom gm@||@com  Wed May  1 17:25:48 2019
From: c@@rd|@g@bor @end|ng |rom gm@||@com (=?UTF-8?B?R8OhYm9yIENzw6FyZGk=?=)
Date: Wed, 1 May 2019 16:25:48 +0100
Subject: [Rd] [External] Re:  Background R session on Unix and SIGINT
In-Reply-To: <36C1770B-5054-4F1F-B508-225A7B8EE3E2@R-project.org>
References: <CABtg=Km=Bj_gDr3jsYSvQf479eJhPunRYyU8UQEfaV-YtKvqqQ@mail.gmail.com>
 <3A2C4184-FD39-410A-8392-28C473AAC8D0@R-project.org>
 <CABtg=KkfXU4+7F=Yr2=v=ssg=-naEkYDGM_A6j7UGNWSkjVoTw@mail.gmail.com>
 <EDAD9282-9026-4B88-A1A3-B2A63A6ADC3E@R-project.org>
 <CABtg=Knor462S640xB8bAZbMG+TAq7hur14gaBTt4aUiP5mXoQ@mail.gmail.com>
 <alpine.DEB.2.21.1904301641090.2842@luke-Latitude-7480>
 <CABtg=K=N2ewB5KaEUXwmtqQuDEfVAVS=3HXBNokaVoyrOKVVPw@mail.gmail.com>
 <36C1770B-5054-4F1F-B508-225A7B8EE3E2@R-project.org>
Message-ID: <CABtg=KmFCR+PfwL38V3746VFtp-K2wqyzWGQ3udva=O=h+L1jw@mail.gmail.com>

On Wed, May 1, 2019 at 4:20 PM Simon Urbanek
<simon.urbanek at r-project.org> wrote:
> 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.

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.

> 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.

Yes, that's exactly what I am doing. Thanks again!

Gabor

[...]



[Rd] [External] Re: Background R session on Unix and SIGINT
=?UTF-8?B?R8OhYm9yIENzw6FyZGk=?=