Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: flock() ..I really need a hand .. please :)

by AgentM (Curate)
on Mar 20, 2001 at 10:01 UTC ( [id://65635]=note: print w/replies, xml ) Need Help??


in reply to flock() ..I really need a hand .. please :)

You'll be glad to know that a file-based semaphore already exists on CPAN as File::CounterFile. Pick it up!
AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.
  • Comment on Re: flock() ..I really need a hand .. please :)

Replies are listed 'Best First'.
Re: Re: flock() ..I really need a hand .. please :)
by Anonymous Monk on Mar 20, 2001 at 12:17 UTC
    Hello, Thank you all for your wisdom. I do appreciate the help & tips:

    a, just to clarify, all the files were using the same $SEMAPHORE file, so any instance of $tempfile getting written to, $tempfile was locked. I double checked the locks as well, by placing the sleep method KM had discussed. The lock was working when I had checked. (Using the names "$tempfile" and "$file" were actually just examples, in the code the real file names are placed instead.)

    I dunno, I've gone over this a bizillion times and double checked everywhere, and it only happens once in a while where the file gets wiped. I really like KM's method because it does make sense, and that's probably the first time flock() actually makes sense to me. I would guess it's better than when I first began using just flock(FILE,2);

    I'll keep plunking away at it, and hopefully I'll get something that will work. Also thanks for the tip to debug "rename" I'll add that right away.

    AgentM Thank you for letting me know about the module File::CounterFile I went and took a look, it looks interesting enough, but it says under Bugs that it uses the flock(2); method. This was something I was trying to avoid. What are your feeling on that?

    Well Thanks again, I do appreciate the help :-)

    PS.. Thanks turnstep that search was great!!

      The "bug" reports that flock is not entirely cross-platform (it's emulated decently on most systems which don't natively support flock but do support advisory locking). That simply means the target system needs to support flock (advisory locks). The report suggests a File::Lock module which doesn't exist (perhaps a good idea).
      AgentM Systems nor Nasca Enterprises nor Bone::Easy nor Macperl is responsible for the comments made by AgentM. Remember, you can build any logical system with NOR.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://65635]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (1)
As of 2024-04-25 01:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found