[R] mkChar can be interrupted

Vadim Ogranovich vograno at evafunds.com
Mon Jun 14 20:55:21 CEST 2004

As was discussed earlier in another thread and as documented in R-exts
.Call() should not be interruptible by Ctrl-C. However the following
code, which spends most of its time inside mkChar, turned out to be
interruptible on RH-7.3 R-1.8.1 gcc-2.96:
#include <Rinternals.h>
#include <R.h>

SEXP foo0(const SEXP nSexp) {
  int i, n;
  SEXP resSexp;

  if (!isInteger(nSexp))
    error("wrong arg type\n");

  n = asInteger(nSexp);
  resSexp = PROTECT(allocVector(STRSXP, n));
  Rprintf("!!!time to interrup!!!\n");
  for (i=0; i<n; ++i) {
    SET_STRING_ELT(resSexp, i, mkChar("foo"));

  Rprintf("end mkChar\n");
  return R_NilValue;

# invoke 'foo0' and give it an argument large enough to let you type
# double the argument if you see "end mkChar" and do it again :-)
> x <- .Call("foo0", as.integer(1e7))
!!!time to interrup!!!

> version
platform i686-pc-linux-gnu
arch     i686             
os       linux-gnu        
system   i686, linux-gnu  
major    1                
minor    8.1              
year     2003             
month    11               
day      21               
language R                


More information about the R-help mailing list