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



On a sunny day (Sun, 24 Jun 2007 00:59:43 +0200) it happened Michal Nazarewicz
<mina86@xxxxxxx> wrote in <877ipuqnts.fsf@xxxxxxxxxxxxxxxx>:

I'm not saying that you have to lock one of the data files, however
if it would be possible for two newsreader operate on the same data
files I think that would be the best option.

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.

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.

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.....

Do you want to be mentioned in the code so if it does not work they can come
after you?

.



Relevant Pages

  • Re: My way to check if a progam is already running
    ... with all the data files. ... if you keep all the configuration and ... I thought you did mean lock every single file. ... The main advantage I see is not the task switch ...
    (comp.os.linux.development.apps)
  • Re: Promises, promises
    ... I bring up my newsreader and ask it to download the latest messages ... It would have been fun to lock you in a room with Rene Magritte....r ...
    (alt.usage.english)
  • Re: [PATCH 3/7] barrier: a scalable synchonisation barrier
    ... I am proposing ... For the first "if" to give a false positive, a concurrent switch had ... While doing qrcu, somehow I convinced myself we can't optimize out taking ... Before, we held the lock, so we could just check the single current ...
    (Linux-Kernel)