[ale] Only one process

JK jknapka at kneuro.net
Sat Jun 5 09:47:33 EDT 2010


On 6/5/2010 7:06 AM, Jim Kinney wrote:
> Since lsof will show a file open for execution before a write of the pid
> is committed, use a grep on lsof for the count of opened copies. If
> greater than one, exit.


Still racy.  Two instances could start, both see more than one
copy of itself running, and bail without doing anything at all.
All you need is a context switch before lsof gets to run, and
there's lots of room for that.

Of course, the naive solution of just checking for /var/myname.pid
will work 99% of the time, but when it doesn't, you'll be
completely baffled.

-- JK



-- 
Forget Jesus: stars died so that you could be here today.
  - physicist Lawrence Krauss


More information about the Ale mailing list