PDA

View Full Version : syslog calls and threading



rotis23
06-27-2005, 03:40 AM
Hi All,

To ensure thread-safety of syslog(3) calls with pthread child threads, should I make a fresh openlog(3) call? I've had weird hangs with syslog calls on my red hat system and I don't have syslog_r available on my system.

I guess I just want to know if it's safe to call syslog with child threads or not :confused: There's not much concrete info out there :(

Thanks, rotis23

jim mcnamara
06-27-2005, 01:21 PM
My version of the man page 3 thread_safety lists syslog() as not cancellation safe or asynch signal safe. It's not atomic, in other words.

You're better off handling those types of calls by blocking all blockable signals when the call is active. We don't call syslog() with child threads, but I personally don't know if it's safe or not. Here is another opinion on another platform:

http://www.essenz.com/support/lists/hackers/20041010/61.html

rotis23
06-28-2005, 09:49 AM
Thanks Jim.

It seems pretty obvious to me that syslog is not safe on my redhat system.

I need syslog_r.