Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: Locking files

by claree0 (Hermit)
on Aug 10, 2001 at 16:45 UTC ( #103854=note: print w/replies, xml ) Need Help??

in reply to Locking files

My first instinct would to have the first thing does be check the process list for number of instances of that prog, and exit if more than one....then you don't need to lock/unlock (and I can't think of a way to do that), just exit early.

Replies are listed 'Best First'.
Re: Re: Locking files
by Ras (Acolyte) on Aug 10, 2001 at 17:03 UTC
    I don't understand what you mean claree0. Can you show me some kind of example. thanks.

      Assuming that you are doing this on some sort of unix-like OS, then grepping the output of `ps ax | grep | wc -l` ought to give you the current number of running processes from that program. If 1 then it is the only instance. If 2 then another is already running, and you can exit the new instance.

      There may be a better way of doing this without making calls outside perl - I still talk 'perl baby-talk' quite a lot!


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2022-10-06 07:16 GMT
Find Nodes?
    Voting Booth?
    My preferred way to holiday/vacation is:

    Results (26 votes). Check out past polls.