in reply to Testing if your code successfully flocked
I think so!
to test, fork a new process, and try to open and flock the same file both in the child and in the parent with the NB option, check that one succeeds and the other fails.
Other way, fork 10 processes, make all them wait some random seconds, flock the file, read some number for it, sleep other some random seconds, write the number incremented. On the parent wait for all the processes to exit, check that the number in the file is 10.
|
|---|