IO Streams thread-safe in MacOSX?


I'm using fread() and fseek() stream IO functions in a multi-threaded application. Unfortunately, the data returned by fread() is not correct. From the bytes it returns, I can tell that the internal buffers of the various FILE* objects (one per thread) are interfering with each other.

The same code (C++) works fine on Windows.

Does anyone have any thoughts on whether the MacOS stdio stream library (fread and so on) is thread safe?

Thanks in advance for any help,


It may be a good idea to use fscanf() or fgets(3) for secure input... I have not had too much trouble with standard libraries in OSX, with the exception of gets(). The question is, are you terminating the proper streams at the proper times using fclose()? A good reference for using c standard libraries can be found here.