in reply to Re: Abort if instance already running?
in thread Abort if instance already running?
$SIG{'INT'} = \&release_lock; $SIG{'QUIT'} = \&release_lock; $SIG{'PIPE'} = \&release_lock; #maybe too? sub release_lock{ #...do what you can here... }
The basic idea is not to leave locks around if your program abends. The lock strategy is simple, works well, and can be implemented in many languages on many O/s'es (some easier than others)..just remember to clean up if "bad things" happen to your program and the normal "release lock" code doesn't execute.
The lock system is cooperative, meaning that everybody has to know what is going on and cooperate. It is possible to write a file that is "locked" for exclusive access. A file lock is more like an advisory thing and the programs that use it have to "play by the rules".
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Abort if instance already running?
by graff (Chancellor) on Jan 06, 2009 at 02:30 UTC | |
by Marshall (Canon) on Jan 06, 2009 at 03:16 UTC | |
by rir (Vicar) on Jan 06, 2009 at 21:40 UTC | |
|
Re^3: Abort if instance already running?
by JavaFan (Canon) on Jan 06, 2009 at 08:03 UTC |