A simple question:
I need to add some logging to my program.
If two processes use “fwrite” on the same file but not the same file descriptor will the written log messages be atomic or mixed. Is there a length limit?
Is it defined ANSI-C behaviour or implementation defined?
If the later what is on MacOSX, Linux and Windows MSVC?
It can be mixed.
If you have more than one thread/process writing to the same file, you need to use locking.
An alternative is to send log messages to a dedicated service/thread. An excellent tool to adopt is syslog, which is surely installed on all unixes and can be run on Windows.