kaykun kaykun - 2 years ago 135
C Question

Is open thread safe?

Is it okay if two threads call open() at the same time? How would one find the answer to this question?

Assume that the calls are operating on different files, and their flags can be

, or both.

Answer Source

Since you note they are different files, then there isn't a problem.

It's no different that two different processes opening two different files.

Edit: It would be fair to mention, as Guy notes below in the comments, that this was not always the case. It is dependent on whether the libc you are using is threadsafe. Modern incarnations are in regard to the open() call.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download