Re: Single instances?
On Jun 14, 8:45 am, "somnath...@gmail.com" <somnath...@gmail.com>
wrote:
On Jun 14, 11:12 am, Erik Wikstr=F6m <eri...@student.chalmers.se> wrote:
On 14 Juni, 07:34, linarin <lin.jian...@gmail.com> wrote:
You can create a file in user's home directory act as mutex,and
testing file existence to see is there have an instance running.
And hope your application does not crash before it deletes the file.
Implement signal handler to catch signals and delete file before
aborting.
You can't catch all signals, and theoretically, at least, you
can't call remove() from a signal handler (although I think it
will work under both Unix and Windows).
The classical solution is either to ask the user when you find
the file, and let him decide if you start anyway, at his risks
and perils, or to write the process id into the file, and when
you find it on start-up, read the process id, then ask the
system (very system dependant) if such a process is still
running.
--
James Kanze (GABI Software, from CAI) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34