Would any other instance of the same program be able to get passed the get_lock(); line without obtaining a lock first? Shouldn't the get_lock(); line make all instances of the same program "wait their turn" to get a lock before proceeding so that only one instance of the program gets to "Do something here" at a time? Thanks in advance.sub get_lock { open(SEM, ">$semaphore_file") || die "Cannot create semaphore: $!"; flock(SEM, LOCK_EX) || die "Lock failed: $!"; } sub release_lock { close(SEM); } $semaphore_file="semfile"; get_lock(); #Do something here release_lock;
In reply to Lock Effectivity by Gorby
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |