Re: My way to check if a progam is already running



On 23 jun, 15:18, Michal Nazarewicz <min...@xxxxxxx> wrote:
Jan Panteltje <pNaonStpealm...@xxxxxxxxx> writes:
On Sat, 23 Jun 2007 12:05:34 +0200 it happened Michal Nazarewicz
<min...@xxxxxxx> wrote in <871wg3j89d....@xxxxxxxxxxxxxxxx>:

With the above code I think it is not possible to start two instances in
such a way that both will continue running. The worst case is that they
both will abort. (It's still a bug.)

I still don't see why you don't want to lock a file at the start and
unlock it when program terminates. It's way simpler operation:

Yes, but then you have 2 GUI up for example,

??? How locking a file lock differs from getting number of applications
with given name? Simply replace your checking routine with what I wrote
and you have the same functionality but more portable and without any
bugs.

Maybe I do not understand you, but for example in this newsreader
there is not
just _one_ file, there are many (one for each newsgroup, one or more
for each posting, some for fonts, some for other purposes, some to
hold all groups,
some for indexes, for article headers, one for each article body, and
also these
files are created when needed (for example you subscribe to a group or
post a reply, edit a text, what not).
So it is not really possible to 'just lock at the start of the
program', the issue is
that no second program SHALL run, because if it does not run it
_CANNOT_ do things to files it should not do.

More unlike putting a lock on each inside door, just have one of the
gate.
Makes life easier if you live there.


.



Relevant Pages