[R-SIG-Mac] Strange issue with STOP button

Matthew Denwood m.denwood at vet.gla.ac.uk
Sat Apr 7 00:54:25 CEST 2012


Hi all

I have come across a slightly strange issue with using the STOP button to suspend R computation in the Mac GUI (R 2.15.0 GUI 1.51 Leopard build 64-bit (6148) - although thinking back I'm fairly sure I have had the same issues with much earlier versions of R).  Basically, after a call to system() the STOP button is greyed out and not active until execution returns to the top level, even though further R computation is occurring after the system call.  For instance when running the following code:

f <- function(){
	
	system2("ls", stdout=FALSE, stderr=FALSE, wait=TRUE)
	
	i <- 1
	repeat{
		cat(i,sep="\n")
		flush.console()
		Sys.sleep(1)
		i <- i+1
	}

}

f()

... it is not possible to use the STOP button to escape the endless repeat because (for me at least) it is greyed out as if there is no active computation happening, although the ESC key does work as expected.  I have tried changing arguments to system and enclosing the system call in another function and tryCatch statement, but get the same result.  However, if you move the system2 call to the bottom of the function then STOP breaks the function during the endless loop as expected, and running the code from inside the function also works fine (I assume because control is returned to the top level of R between the system2 call finishing and the repeat loop starting).

Anybody got any ideas of what's going on, or is this just a weird bug?  Admittedly it isn't a critical issue as ESC appears to be unaffected, but it doesn't seem like expected behaviour to me!

Cheers,

Matt


More information about the R-SIG-Mac mailing list