> On Tue, Oct 30, 2001 at 07:40:47PM -0500, John Tobey wrote:
> > I would guess so, but I would be more confident if you added ||
> > die("LOCK_EX: $!") after flock.
>
> Two potentially non-obvious but traditional
> "flock" semantics are that it waits indefinitely
> until the lock is granted, and ...
In that case, wouldn't an eval/alarm block work?
I mean,
eval {
local $SIG{ALRM} = sub { die "Hurg. Can't lock file" };
alarm $seconds_to_wait;
flock($fh, LOCK_EX);
alarm 0;
}
if ($@) {
# lock timed out
} else {
# locked
}
--
Jona Andersen
Dork in Training