in reply to SOLVED [flock on Ubuntu 9.10]

You are using flock(FH, LOCK_EX) which will wait until the lock is available. Easy to see if you put a print before and after the flock.

Add the non-blocking flag to get an instantaneous read on the lock state: flock(FH, LOCK_EX|LOCK_NB). Import the constants with use Fcntl qw(:flock);.

Replies are listed 'Best First'.
Re^2: flock on Ubuntu 9.10
by poctob (Initiate) on Nov 14, 2009 at 03:09 UTC
    What can I say you and ikegami hit the nail right on the head. Adding non-blocking flag did the trick. The only thing I would like to add, so not really related to my original post, is that if Proc::Daemon::Init is used to daemonize the process, flock call has to be after Proc::Daemon::Init call, otherwise Proc::Daemon::Init releases the lock as it forks the app. Thank you!
      Part of daemonizing involves forking and exiting the current process. Proc::Deamon uses exit to exit the current process. This closes open file handles, releasing associated locks.