From luke-tierney at uiowa.edu  Tue Nov 21 19:42:15 2017
From: luke-tierney at uiowa.edu (luke-tierney at uiowa.edu)
Date: Tue, 21 Nov 2017 12:42:15 -0600 (CST)
Subject: [Rd] Are Rprintf and REprintf thread-safe?
In-Reply-To: <CAFOpNVG48s4mahtM3nFkedParKJtoGkR5WPZOhg6bhaz-W43sg@mail.gmail.com>
References: <CAFOpNVG48s4mahtM3nFkedParKJtoGkR5WPZOhg6bhaz-W43sg@mail.gmail.com>
Message-ID: <alpine.DEB.2.20.1711211239350.2642@luke-Latitude>

On Tue, 21 Nov 2017, Winston Chang wrote:

> Is it safe to call Rprintf and REprintf from a background thread? I'm
> working on a package that makes calls to fprintf(stderr, ...) on a
> background thread when errors happen, but when I run R CMD check, it
> says:
>
>  Compiled code should not call entry points which might terminate R nor
>  write to stdout/stderr instead of to the console, nor the system RNG.
>
> Is it safe to replace these calls with REprintf()?

Only if you enjoy race conditions or segfaults.

Rprintf and REprintf are not thread-safe.

Best,

luke


>
> -Winston
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
Luke Tierney
Ralph E. Wareham Professor of Mathematical Sciences
University of Iowa                  Phone:             319-335-3386
Department of Statistics and        Fax:               319-335-3017
    Actuarial Science
241 Schaeffer Hall                  email:   luke-tierney at uiowa.edu
Iowa City, IA 52242                 WWW:  http://www.stat.uiowa.edu



[Rd] Are Rprintf and REprintf thread-safe?
luke-tierney at uiowa.edu