in reply to Exec or system functions
Another answer is to open/lock a file -- if it fails (for a specific reason) then someone else has the file open and locked: your other instance.
One way I like to do it is to bind a specific network port on localhost. You don't actually have to listen to the port, just bind it. Only one "process" can bind a port at a time. If you try to bind and it's already bound, then there's already an instance of you running. (Note: pick a good out-of-the-way port number...) It's a portable technique and almost foolproof.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Exec or system functions
by rchiav (Deacon) on Jul 16, 2001 at 05:49 UTC |