flock("test.pid", LOCK_EX | LOCK_NB)

Just starting out? Need help? Post your questions and find answers here.
swhite
Enthusiast
Enthusiast
Posts: 727
Joined: Thu May 21, 2009 6:56 pm

flock("test.pid", LOCK_EX | LOCK_NB)

Post by swhite »

Hi

Is it possible to use the flock() function on a file to obtain an exclusive lock? Something like the following:

Code: Select all

flock("test.pid", LOCK_EX | LOCK_NB)
I understand it is advisory but it would tell me if some process had applied a lock and then I could take the appropriate action.

Thanks,
Simon
Simon White
dCipher Computing