[Rd] Capture output of install.packages (pipe system2)

Jeroen Ooms jeroen.ooms at stat.ucla.edu
Tue Sep 24 20:00:42 CEST 2013


On Mon, Sep 23, 2013 at 6:34 PM, Simon Urbanek
<simon.urbanek at r-project.org> wrote:
> On top of my head for full capture I can only think of custom C code that will re-direct stderr/out FDs as desired (it's really trivial to re-direct to files, for dynamic capture it's a little more involved but there are examples that do that).

I had secretly been hoping that system2("whoami", stdout=stdout(),
stderr=stderr()) would capture output streams from the child process
and concatenate to stdout() and stderr() in the parent just as if they
were sent by cat("foo", file=stdout()) and cat("bar", file=stderr())
such that they could be captured from sink() in the parent. However
thinking twice about this, it is probably very difficult to implement
without threads. The event loop in the parent process would need to
poll for buffered output in the child while waiting for it to return
or something.



More information about the R-devel mailing list