> Well, fprintf() doesn't have to acquire the lock for the entirety of
> it's operation - just for the access to the stream buffer.
Yep. If it is implemented by appending stuff to the stream as the format
is processed, this would still mean the whole time of its operation.
Hence preprocessing the string as you suggested may be desirable.
> Note that posix 2001 *does* guarantee that FILE* style IO is thread
> safe:
> "All functions that reference (FILE *) objects, except those with names
> ending in _unlocked, shall behave as if they use flockfile() and
> funlockfile() internally to obtain ownership of these (FILE *) objects."
>
> Hilariously that tidbit hidden in the documentation about
> flockfile. Very, err, easy to find:
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/flockfile.html
Thanks for the pointer!
--
Fabien.