Is fprintf thread-safe? The glibc manual seems to say it is, but my application, which writes to a file using single call to fprintf() seems to be intermingling partial writes from different processes.
edit: To clarify, the program in question is a lighttpd plugin, and the server is running with multiple worker threads.
Looking at the file, some of the writes are intermingled.
edit 2: It seems the problem I'm seeing might be due to lighttpd's "worker threads" actually being separate processes: http://redmine.lighttpd.net/wiki/lighttpd/Docs:MultiProcessor
Problems
By running 2 or more processes on the same socket you will have a better concurrency, but will have a few drawbacks that you have to be aware of:
- mod_accesslog might create broken access logs, as the same file is opened twice and is NOT synchronized.
- mod_status will have n separate counters, one set for each process.
- mod_rrdtool will fail as it receives the same timestamp twice.
- mod_uploadprogress will not show correct status.