From c@@rd|@g@bor @end|ng |rom gm@||@com  Tue Apr 30 22:17:58 2019
From: c@@rd|@g@bor @end|ng |rom gm@||@com (=?UTF-8?B?R8OhYm9yIENzw6FyZGk=?=)
Date: Tue, 30 Apr 2019 21:17:58 +0100
Subject: [Rd] Background R session on Unix and SIGINT
In-Reply-To: <3A2C4184-FD39-410A-8392-28C473AAC8D0@R-project.org>
References: <CABtg=Km=Bj_gDr3jsYSvQf479eJhPunRYyU8UQEfaV-YtKvqqQ@mail.gmail.com>
 <3A2C4184-FD39-410A-8392-28C473AAC8D0@R-project.org>
Message-ID: <CABtg=KkfXU4+7F=Yr2=v=ssg=-naEkYDGM_A6j7UGNWSkjVoTw@mail.gmail.com>

Yeah, I get that they are async.

What happens is that the background process is not doing anything when
the process gets a SIGINT. I.e. the background process is just
listening on its standard input.

AFAICT for an interactive process such a SIGINT is just swallowed,
with a newline outputted to the terminal.

But apparently, for this background process, it is not swallowed, and
it is triggered later. FWIW it does not happen on Windows, not very
surprisingly.

Gabor

On Tue, Apr 30, 2019 at 9:13 PM Simon Urbanek
<simon.urbanek at r-project.org> wrote:
>
> Interrupts are not synchronous in R - the signal only flags the request for interruption. Nothing actually happens until R_CheckUserInterrupt() is called at an interruptible point. In you case your code is apparently not calling R_CheckUserInterrupt() until later as a side-effect of the next evaluation.
>
> Cheers,
> Simon
>
>
> > On Apr 30, 2019, at 3:44 PM, G?bor Cs?rdi <csardi.gabor at gmail.com> wrote:
> >
> > Hi All,
> >
> > I realize that this is not a really nice reprex, but anyone has an
> > idea why a background R session would "remember" an interrupt (SIGINT)
> > on Unix?
> >
> > rs <- callr::r_session$new()
> > rs$interrupt()     # just sends a SIGINT
> > #> [1] TRUE
> >
> > rs$run(function() 1+1)
> > #> Error: interrupt
> >
> > rs$run(function() 1+1)
> > #> [1] 2
> >
> > It seems that the main loop somehow stores the SIGINT it receives
> > while it is waiting on stdin, and then it triggers it when some input
> > comes in.... Maybe. Just speculating....
> >
> > Thanks,
> > Gabor
> >
> > ______________________________________________
> > R-devel at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> >
>



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