I believe any non entertain the project will have a log of this function, while some of the projects would certainly be a little more complex multi-threaded implementation process, so whether it is by your own wheels or online Grilled code, we will see a bunch write lock on the log module is IO, but also read and write locks, see really a headache, a low tolerance rate is also conceivable, if what has gone wrong, it is estimated death on all cards.
Tragedy is in fact the standard library with a c fwrite, operating system help you solve all the problems, MSDN is so right:
The fwrite function writes up to count items, of size length each, from buffer to the output stream. The file pointer associated with stream (if there is one) is incremented by the number of bytes actually written. If stream is opened in text mode , each carriage return is replaced with a carriage-return - linefeed pair. The replacement has no effect on the return value.
This function locks the calling thread and is therefore thread-safe. For a non-locking version, see _fwrite_nolock.
Which is almost famous APUE
If multiple processes, threads using standard I / 0 Tianxie way to open the same file, then from each process, thread data is correctly written to file.
Then, the log module directly to end up with fwrite additional