[Rd] Bug when calling system/system2 (and request for Bugzilla account)
kevinu@hey @ending from gm@il@com
Fri Sep 14 19:58:48 CEST 2018
FWIW I can reproduce on macOS with R 3.5.1. A smaller example:
system2("ls", timeout = 5); x <- sample(1:1E8)
If I try to interrupt R while that sample call is running, R itself is closed.
On Fri, Sep 14, 2018 at 10:53 AM Emil Bode <emil.bode using dans.knaw.nl> wrote:
> I hope it's not too specific in my setup...
> I've tried with system2 added on the first line, so:
> system2('ls', timeout=5)
> cat('Start non-interruptable functions\n')
> sample_a <- sample(1:1e7)
> sample_b <- sample(1:2e7)
> matching <- match(sample_a, sample_b)
> And in terminal/bash:
> R --vanilla
> Send ^C between the messages (Start... until Finished)
> Or if you have a more powerful CPU you can increase the samples, the exact code doesn't matter very much.
> As soon as you restart and source again with the system2 call outcommented, the behaviour is different, there is a pause, and your return to the R-prompt.
> Best, Emil
> On 14/09/2018, 17:39, "luke-tierney using uiowa.edu" <luke-tierney using uiowa.edu> wrote:
> I can't reproduce this. Can you be more precise: exactly where are you
> putting the system2 call and exactly where are you sending the
> interrupt signal with ^C?
> On Fri, 14 Sep 2018, Emil Bode wrote:
> > Hi all,
> > I found some strange behaviour, which I think is a bug. Could someone make an account for me on Bugzilla or pass on my report?
> > The problem:
> > When pressing Ctrl-C when a file is sourced in R, run from Terminal (macOS), sometimes the entire session is ended right away, while I just want to stop the script. This is the case when I press Ctrl-C while some functions are running that don’t catch the interrupt. However, the behaviour is different whether I’m in a clean session (in which case some time is allowed to pass, so that when the function returns the script can be interrupted), or whether I have called base::system() or system2() with timeout other than 0.
> > Reproducible example:
> > cat('Start non-interruptable functions\n')
> > sample_a <- sample(1:1e7)
> > sample_b <- sample(1:2e7)
> > matching <- match(sample_a, sample_b)
> > cat('Finished\n')
> > Sys.sleep(10)
> > Observed behaviour:
> > In a clean session, when I hit Ctrl-C during the execution of match, there is a delay, and as soon as Sys.sleep() is invoked, the script is interrupted, I get back my R “>”-prompt (unless options(error=…) is set)
> > But If I add the line system2("ls", timeout = 5), or something similar, when I try to break during the first part of the script, my Rsession ends, I get thrown back to my terminal-prompt.
> > Desired behaviour:
> > The best setup would probably be if Ctrl-C would always try to break from the sourced file, and only if that doesn’t success in n seconds, break the rsession altogether, ideally with a customizable option. But maybe that’s too hard, so maybe the most pragmatic would be to have 2 hotkeys: one to break from a hanging/broken rsession, and one to gently try to break from a script. But at least I think it should be:
> > Expected behaviour:
> > Consistent behaviour for Ctrl-C: either trying to break the script, or end the session altogether.
> > Some observations:
> > * I can still break cleanly during the Sys.sleep(). But for larger scripts, it is largely a matter of luck if I hit Ctrl-C during the right moment.
> > * I don’t notice any difference between using system or system2, or any of the arguments other than timeout provided
> > * I don’t notice any difference whether the timeout is actually exhausted or not.
> > * Later calls to system/system2 don’t change anything (i.e. later calling system(…, timeout=0) does not revert back to the old situation)
> > My setup:
> > R 3.5.1 (Feather Spray), run with –vanilla option
> > GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin17)
> > macOS High Sierra 10.13.6
> > Best regards,
> > Emil Bode
> > Data-analyst
> > +31 6 43 83 89 33
> > emil.bode using dans.knaw.nl<mailto:emil.bode using dans.knaw.nl>
> > DANS: Netherlands Institute for Permanent Access to Digital Research Resources
> > Anna van Saksenlaan 51 | 2593 HW Den Haag | +31 70 349 44 50 | info using dans.knaw.nl<mailto:info using dans.kn> | dans.knaw.nl<applewebdata://71F677F0-6872-45F3-A6C4-4972BF87185B/www.dans.knaw.nl>
> > DANS is an institute of the Dutch Academy KNAW<http://knaw.nl/nl> and funding organisation NWO<http://www.nwo.nl/>.
> > [[alternative HTML version deleted]]
> > ______________________________________________
> > R-devel using r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> Luke Tierney
> 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-tierney using uiowa.edu
> Iowa City, IA 52242 WWW: http://www.stat.uiowa.edu
> R-devel using r-project.org mailing list
More information about the R-devel