Ricardo Saporta
Ricardo Saporta

Reputation: 55350

Avoiding rJava related System Exit on ctrl+c when using R in terminal

Simon Urbanek and others have indicated that to prevent ctrl+c from causing R to quit, one "needs to add -Xrs java option so the JVM doesn't steal SIGINT from R"

My question is Where should this -Xrs flag be added? Clearly not when calling library(rJava). Perhaps on install?

> is.friends(Me, Java)
[1] FALSE

(I rarely call rJava, rather it's normally called simply as a dependency, by eg XLconnect. Nevertheless, if I hit ctrl+c to attempt to break a run in R, the entire program quits.)

Upvotes: 3

Views: 224

Answers (1)

agstudy
agstudy

Reputation: 121568

you can pass parameters to the JVM just like you do to a command line Java process via rJava options support than you load your library. For example:

## sets the maximum Java heap size to 1024
options (java.parameters = "-Xmx1024m" ) 
## to prevent the Java runtime environment handling 
## exception signals such SIGSEGV and SIGABRT
options (java.parameters = "-Xrs" ) 

Then you load library as usual:

library ( XLConnect )

EDIT

If a package is loading rJava you can specify these flags:

.jinit(classpath="myClasses.jar", parameters="-Xmx512m")

Upvotes: 2

Related Questions