r_eval_subprocess: Run R code in an isolated subprocess with safety layers

View source: R/r_introspect_tools.R

r_eval_subprocessR Documentation

Run R code in an isolated subprocess with safety layers

Description

Uses callr::r_bg() plus a polling loop so the parent session can react to Ctrl-C while a long-running or persistent subprocess (e.g. system("vim"), a hung network call) is executing. On timeout OR interrupt the subprocess and its whole process tree are killed via process$kill_tree().

Usage

r_eval_subprocess(
  code,
  timeout_secs = 30,
  working_dir = NULL,
  libpaths = NULL,
  envvars = NULL,
  share_credentials = FALSE
)

aisdk documentation built on May 29, 2026, 9:07 a.m.