Folks, I can't find the re-entrant version of syslog() for Linux...is there one? And if no, what do you? The obvious answer is to move logging facility into separate thread and serialise access to syslog...
Asked
Active
Viewed 6,072 times
1 Answers
19
According to the POSIX specification, the syslog function is already thread-safe, and so implemented in Linux. So syslog_r is unnecessary - use syslog if you need a reentrant logger function.

Martin v. Löwis
- 124,830
- 17
- 198
- 235
-
5The BSDs define a syslog_r call, however, for an entirely different reason; individual threads may want to log with different syslog options, which is not otherwise possible. – Michiel Buddingh Jul 22 '09 at 05:45
-
-
[this page](http://pic.dhe.ibm.com/infocenter/aix/v6r1/index.jsp?topic=%2Fcom.ibm.aix.basetechref%2Fdoc%2Fbasetrf2%2Fsyslog.htm) says it is not thread safe – BЈовић Sep 04 '13 at 08:35
-
Is this still the case with `syslog`? I can find no mention of thread safety or reentrant behaviour in the POSIX specification. – Michael Foukarakis Jun 19 '14 at 12:24
-
Glibc docs now note the "safety" properties, and say syslog is thread-safe: http://www.gnu.org/software/libc/manual/html_node/syslog_003b-vsyslog.html#syslog_003b-vsyslog – P.T. Apr 01 '15 at 06:56