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



On a sunny day (Mon, 25 Jun 2007 14:31:06 -0700) it happened David Schwartz
<davids@xxxxxxxxxxxxx> wrote in
<1182807066.946422.180340@xxxxxxxxxxxxxxxxxxxxxxxxxxxx>:

On Jun 25, 4:10 am, Jan Panteltje <pNaonStpealm...@xxxxxxxxx> wrote:

EAGAIN means test again, and I have tested this soft and forced the
EAGAIN condition.
Unless (we still have to look at the lockf() source) EAGAIN is used wrongly,
the loop is correct.

I have see errno values been used wrongly before.
It is just playing safe.

Err, what?! EAGAIN does not mean "test again", it means the file is
locked. Since that was what you wanted to know, ...

You seem *extremely* confused.

Na, it says:

F_TEST Test the lock:
return 0 if the specified section is unlocked or locked by this process;
return -1, set errno to EACCES, if another process holds a lock.

Not a word on the other error codes here, but further down:
ERRORS
EAGAIN The file is locked and F_TLOCK or F_TEST was specified,
or the operation is prohibited because the file has been memory mapped by another process.
etc for other errors.

I guess there are several ways one can read that man 3 lockf.
That is why one should look at the source.

So, basically if lockf returns -1 and errno is not EACCESS then some problem must exists.

I have tried several varieties of the code, both testing for EACCES and testing for EAGAIN.
I suggest you try some before you criticise,

Else it is just untried blabber.
.



Relevant Pages

  • Re: My way to check if a progam is already running
    ... This loop is totally useless, because by the time you do the second ... what another lockf call happening in the past returned. ... EAGAIN means test again, and I have tested this soft and forced the EAGAIN condition. ... but errno was EAGAIN then what would you do? ...
    (comp.os.linux.development.apps)
  • Re: My way to check if a progam is already running
    ... what another lockf call happening in the past returned. ... EAGAIN means test again, and I have tested this soft and forced the EAGAIN condition. ... The 'real test' is the lock(..., ... *fer crissake* 'the second loop' refers to THE SECOND LOOP, ...
    (comp.os.linux.development.apps)
  • Re: My way to check if a progam is already running
    ... This loop is totally useless, because by the time you do the second ... what another lockf call happening in the past returned. ... EAGAIN means test again, and I have tested this soft and forced the EAGAIN condition. ... The 'real test' is the lock(..., ...
    (comp.os.linux.development.apps)
  • Re: My way to check if a progam is already running
    ... what another lockf call happening in the past returned. ... EAGAIN means test again, and I have tested this soft and forced the EAGAIN condition. ... Unless source) EAGAIN is used wrongly, the loop is correct. ...
    (comp.os.linux.development.apps)
  • Re: EAGAIN vs EWOULDBLOCK
    ... > Is there any subtle difference between EAGAIN and EWOULDBLOCK? ... On most platforms there is no difference; in fact, the two error codes ...
    (comp.unix.programmer)