Skip to content
Prev 21752 / 63435 Next

stop R mainloop without calling exit(1)

Dear Professor Ripley,

Thank you for your reply. I have a few questions left:
In the documentation  "run_Rmainloop" is called to start the loop:

         Rf_initEmbeddedR(argc, argv);
         /* submit some code to R, which is done interactively via
             run_Rmainloop();
         */
         Rf_endEmbeddedR(0);

But that method doesn't return normally, right? It only ends if
ReplIteration returns -1.
Or do you mean I need to re-implement the read-and-evaluate loop in a
way that I can interrupt it (at "run a loop (which can return)" in
your example)? So instead of calling run_Rmainloop, I can copy the
loop in R_ReplConsole, add an interrupted flag and check that every
iteration.
So for the Unix alikes I could use a customized R_CleanUp for the
non-devel versions of R. For windows I should still call
end_Rmainloop, but if I understand you well, this is only needed if I
use the windows widgets in R. I don't want to, so it shouldn't be a
problem then?

Thank you for your help, I'm going to try to modify the JRI interface
by writing a custom loop instead of calling run_Rmainloop.

By the way, I use R version 2.2.1 in linux, because I got the "Error:
C stack usage is too close to the limit R" error in higher versions (I
saw there was a topic about this already:
https://stat.ethz.ch/pipermail/r-devel/2006-April/037219.html). I
tried to use the R-devel version to make use of the Rf_endEmbeddedR
method, but the error also occurs in this version. Could this be a
bug?

Thomas

2006/8/31, Prof Brian Ripley <ripley at stats.ox.ac.uk>: