[Rd] Bug when calling system/system2 (and request for Bugzilla account)
emil@bode @ending from d@n@@kn@w@nl
Fri Sep 14 15:04:29 CEST 2018
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?
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.
cat('Start non-interruptable functions\n')
sample_a <- sample(1:1e7)
sample_b <- sample(1:2e7)
matching <- match(sample_a, sample_b)
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.
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:
Consistent behaviour for Ctrl-C: either trying to break the script, or end the session altogether.
* 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)
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
+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]]
More information about the R-devel