traxlog has asked for the wisdom of the Perl Monks concerning the following question:
use Fcntl qw(:DEFAULT :flock); use DB_File; # demo purposes only; any db is fine $DBNAME = "/path/to/database"; $LCK = $DBNAME . ".lockfile"; # use O_RDWR if you expect to put data in the lockfile sysopen(DBLOCK, $LCK, O_RDONLY | O_CREAT) or die "can't open $LCK: $!"; # must get lock before opening database flock(DBLOCK, LOCK_SH) or die "can't LOCK_SH $LCK: $!"; tie(%hash, "DB_File", $DBNAME, O_RDWR | O_CREAT) or die "can't tie $DBNAME: $!";
untie %hash; # must close database before lockfile close DBLOCK; # safe to let go of lock now
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: pesky lockfile stays locked
by Joost (Canon) on May 17, 2004 at 11:47 UTC | |
|
Re: pesky lockfile stays locked
by Abigail-II (Bishop) on May 17, 2004 at 13:31 UTC | |
by traxlog (Scribe) on May 17, 2004 at 15:01 UTC | |
by dave_the_m (Monsignor) on May 17, 2004 at 15:10 UTC | |
by Abigail-II (Bishop) on May 17, 2004 at 15:06 UTC | |
by Thelonius (Priest) on May 17, 2004 at 15:24 UTC | |
|
Re: pesky lockfile stays locked
by TilRMan (Friar) on May 17, 2004 at 13:18 UTC | |
by tilly (Archbishop) on May 17, 2004 at 18:49 UTC |