hs*****@usa.com (Hon Seng Phuah) wrote in message news:<38**************************@posting.google. com>...
If I change the open to be write. the flock return 1. Why open read
file cannot use exclusive lock like my case below? Does anyone have
any idea?
To prevent denial of service attacks. (It's an OS feature, nothing to
do with Perl).
Some OSs go futher and disallow taking a shared lock if you have the
file open write-only, which, IMNSHO is just plain dumb.
while (!flock(in_file, LOCK_EX) && $attemp_lock < $max_attempts)
{
sleep(5);
}
You have not specified LOCK_NB. There's no point having a re-try
loop. If a blocking flock() fails it is usually because the
filehandle (or the file) in question is of a type that doesn't support
the type of locking locking you are asking for. This isn't something
that will change in 5 seconds.
Oh, and BTW you forgot to increment your counter.
This newsgroup does not exist (see FAQ). Please do not start threads
here.
Oh, and please don't top-post it is considered rude.