From luke-tier@ey m@ili@g off uiow@@edu  Fri Sep 14 17:39:26 2018
From: luke-tier@ey m@ili@g off uiow@@edu (luke-tier@ey m@ili@g off uiow@@edu)
Date: Fri, 14 Sep 2018 10:39:26 -0500 (CDT)
Subject: [Rd] Bug when calling system/system2 (and request for Bugzilla
 account)
In-Reply-To: <1A6E24FE-022E-44F1-9AB0-58B2DC8A2DB9@dans.knaw.nl>
References: <1A6E24FE-022E-44F1-9AB0-58B2DC8A2DB9@dans.knaw.nl>
Message-ID: <alpine.OSX.2.21.1809141037560.55702@lukes-macbook-air.local>

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?

Best,

luke

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 at dans.knaw.nl<mailto:emil.bode at 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 at dans.knaw.nl<mailto:info at 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 at 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 at uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu


[Rd] Bug when calling system/system2 (and request for Bugzilla account)
luke-tier@ey m@ili@g off uiow@@edu