Re: My way to check if a progam is already running
- From: Michal Nazarewicz <mina86@xxxxxxx>
- Date: Sun, 24 Jun 2007 18:15:57 +0200
On Sun, 24 Jun 2007 00:59:43 +0200 it happened Michal Nazarewicz
<mina86@xxxxxxx> wrote in <877ipuqnts.fsf@xxxxxxxxxxxxxxxx>:
What I'm proposing is to create a lock file for example in a directory
with all the data files. That is, if you keep all the configuration and
data files in "~/.my-newsreader" you can create a file
"~/.my-newsreader/.lockfile" (using int fd = create(foo, 0600)) and then
lock it (using flock(fd, LOCK_EX)). If locking succeed (providing that
you are not using NFS) you're the only application if it fails there's
some application running already.
Jan Panteltje <pNaonStpealmtje@xxxxxxxxx> writes:
Yes, sorry, after posting that last night it hit me that that was what
you were suggesting, I thought you did mean lock every single file.
Yes yours clearly is the best solution, and I will have go at
implementing that. The main advantage I see is not the task switch
issue, but now different users are supported, my solution allowed one
and only one instance to run.
In fact, you can provide a switch for data directory and one user would
then be able to run several instances each running on different data
sets.
I do still maintain that your fear of task switch messing up things were
ungrounded, as for example to start from GUI in my case (fvwm) needs
double click, no way are you doing 2 double clicks within a task switch,
same with key presses.....
I'm not claiming it's likely to happen however it *is* a race condition
and race conditions *are* *bad*.
Do you want to be mentioned in the code so if it does not work they can come
after you?
Doesn't really matter I guess.
--
Best regards, _ _
.o. | Liege of Serenly Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michal "mina86" Nazarewicz (o o)
ooo +--<mina86*tlen.pl>---<jid:mina86*chrome.pl>--ooO--(_)--Ooo--
.
- References:
- My way to check if a progam is already running
- From: Jan Panteltje
- Re: My way to check if a progam is already running
- From: Michal Nazarewicz
- Re: My way to check if a progam is already running
- From: Jan Panteltje
- Re: My way to check if a progam is already running
- From: Michal Nazarewicz
- Re: My way to check if a progam is already running
- From: Jan Panteltje
- Re: My way to check if a progam is already running
- From: Michal Nazarewicz
- Re: My way to check if a progam is already running
- From: Jan Panteltje
- Re: My way to check if a progam is already running
- From: Michal Nazarewicz
- Re: My way to check if a progam is already running
- From: panteltje
- Re: My way to check if a progam is already running
- From: Michal Nazarewicz
- Re: My way to check if a progam is already running
- From: Jan Panteltje
- My way to check if a progam is already running
- Prev by Date: Re: remote control, firefox and document
- Next by Date: Re: remote control, firefox and document
- Previous by thread: Re: My way to check if a progam is already running
- Next by thread: Re: My way to check if a progam is already running
- Index(es):
Relevant Pages
|