[Rd] Ctrl-C with R.exe and Rterm.exe in R v1.9.0

Henrik Bengtsson hb at maths.lth.se
Wed May 5 12:57:29 CEST 2004


Hi, I'm running R v1.9.0 on WinXP Pro. I noticed that R.exe and
Rterm.exe behave differently on Ctrl-C. Starting a Windows Command
prompt (cmd.exe) you get from running Rterm.exe:

C:\Program Files\R>rw1090\bin\Rterm.exe --vanilla --quiet
> ^C
> ^C
> 1+1
[1] 2
> Sys.sleep(100)   # Ctrl-C after a few seconds

> ^C
> ^C
> 1+1
[1] 2
> q()

C:\Program Files\R>
C:\Program Files\R>

Ctrl-C works as expected. Exiting R and you're back at a "clean"
prompt. Now, try the same thing with R.exe (from a restarted prompt):

C:\Program Files\R>rw1090\bin\R.exe --vanilla --quiet
> ^C
> ^C
> 1+1
[1] 2
> Sys.sleep(100)
^C
C:\Program Files\R>
>

Strange things happen. R seems still to be running but has at the same
time returned(?) the control back to the Command prompt. Try to
continue by pressing ENTER and/or type 1 + ENTER, 2 + ENTER etc and
you'll see that eventually you get replied from R also:

> 1+1
'1+1' is not recognized as an internal or external command,
operable program or batch file.

C:\Program Files\R>1+1
'+1' is not recognized as an internal or external command,
operable program or batch file.

C:\Program Files\R>q
C:\Program Files\R>
function (save = "default", status = 0, runLast = TRUE)
.Internal(quit(save, status, runLast))
<environment: namespace:base>
>

Clearly both cmd.exe and R is trying to parse the stdin. Some
keystrokes goes to R and some to cmd.exe.

Best wishes

Henrik Bengtsson

Div. of Mathematical Statistics @ Centre for Mathematical Sciences
Lund Institute of Technology/Lund University, Sweden 
(Sweden +2h UTC, Melbourne +10 UTC, Calif. -7h UTC)
+46 708 909208 (cell), +46 46 320 820 (home), 
+1 (508) 464 6644 (global fax),
+46 46 2229611 (off), +46 46 2224623 (dept. fax)
h b @ m a t h s . l t h . s e, http://www.maths.lth.se/~hb/



More information about the R-devel mailing list