[Rd] Out buffers flushing

Bill Dunlap w||||@mwdun|@p @end|ng |rom gm@||@com
Fri Jan 21 17:25:06 CET 2022


On Linux you could try
    stdbuf --output=L R 2>&1 | cat
to force line buffering when the output goes to a pipe (replace 'cat' by
the command of your choice).  'R' may have to be replaced by the actual
executable, e.g.,
    R CMD stdbuf --output=L `R RHOME`/bin/exec/R 2>&1 | cat

-Bill

On Fri, Jan 21, 2022 at 7:52 AM Greg Minshall <minshall using umich.edu> wrote:

> Roman,
>
> > I'm using R CMD BATCH output stream as control stream (via IPC) in my
> > project. I noticed that sometimes I'm not receiving out line intime
> > (that leads to unwanted behaviour). I suspect it is due to some
> > buffering mechanism. I tried to use flush.console() but it does not
> > help.
>
> so, i'm not quite sure i understand the setup here.  you are running
> some script via `R CMD BATCH`.  that i got.  but i don't know what you
> mean with "(via IPC)".
>
> if when running `R CMD BATCH` on a terminal, your output is showing up
> in a timely way, but when running it some other way, the output is
> delayed, you might try running (on Unix, say) it through a pipe like
> > R CMD BATCH <YOUR_ARGUMENTS_HERE> | cat
> and seeing if you still get the output in a timely way.  if not, then
> there might be some buffering inside the R code that disables buffering
> when going to a terminal, but does buffer when the output is going
> somewhere other than your terminal (this is not uncommon in, e.g.,
> Unix's "standard I/O library").
>
> but, if that pipeline gives output in a timely manner, then maybe your
> "IPC" mechanism is causing the problem.
>
> i don't know if that will be of any help.
>
> cheers, Greg
>
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

	[[alternative HTML version deleted]]



More information about the R-devel mailing list