user152949
user152949

Reputation:

O_EXLOCK vs flock()

What is the difference between calling open() with the O_EXLOCK flag versus calling just calling open() and then calling flock()? The latter has a potential race condition, but other than that both ways gets an exclusive process lock on a file, right?

Upvotes: 3

Views: 2122

Answers (1)

NPE
NPE

Reputation: 500703

The only difference is atomicity: open() with O_EXLOCK is atomic, whereas open() followed by flock() are two distinct operations.

Upvotes: 4

Related Questions