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.
In reply to Re: Exec or system functions
by clintp
in thread Exec or system functions
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |