doc:appunti:prog:perl_flock
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| doc:appunti:prog:perl_flock [2011/02/26 14:45] – niccolo | doc:appunti:prog:perl_flock [2011/02/26 14:56] (current) – niccolo | ||
|---|---|---|---|
| Line 11: | Line 11: | ||
| # Try to lock the file, waiting 5 seconds max. | # Try to lock the file, waiting 5 seconds max. | ||
| + | $i = 0; | ||
| while (! flock(FILE, LOCK_EX | LOCK_NB)) { | while (! flock(FILE, LOCK_EX | LOCK_NB)) { | ||
| if (++$i > 5) { | if (++$i > 5) { | ||
| Line 20: | Line 21: | ||
| # Now the file open and locked. | # Now the file open and locked. | ||
| + | print "File is locked!\n"; | ||
| + | sleep(20); | ||
| # Unlock and close the file. | # Unlock and close the file. | ||
doc/appunti/prog/perl_flock.1298727940.txt.gz · Last modified: by niccolo
