[R-pkg-devel] Catching console messages from libGL

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Tue Feb 18 15:51:08 CET 2020


On 17/02/2020 4:10 p.m., Ivan Krylov wrote:
> On Mon, 17 Feb 2020 14:56:31 -0500
> Duncan Murdoch <murdoch.duncan using gmail.com> wrote:
> 
>> So how do I capture stderr (or, off topic here, how do I get libGL to
>> be quiet)?
> 
> libGL seems to only offer bad news in this regard: it writes directly
> to stderr [1] and does not seem to offer a way to silence the
> _LOADER_FATAL messages [2], which "failed to load driver: %s" are.
> 
> (You have found that out while I was preparing the message.)
> 
> As far as I understand do_sink(), it does not touch the actual stdout
> or stderr, only R's wrappers of them. You probably know better than me
> how portable would it be to try to reassign stderr (which the standard
> says is a macro) to open_memstream() (which is POSIX.1-2008 only).
> 

Thanks for that last paragraph.  I've decided to temporarily redirect 
stderr to /dev/null (or nul on Windows) using dup() and dup2() in the 
C++ code.  I'll make this optional; if people want to see those 
messages, there'll be a way to enable them again.  My tests show that 
this does silence libGL.

Duncan Murdoch



More information about the R-package-devel mailing list