[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-smp
Subject:    Re: threads and file locking doesn't work correct
From:       Berend Reitsma <berend () united-info ! com>
Date:       1998-02-24 12:28:12
[Download RAW message or body]

On Tue, 24 Feb 1998 kukuk@uni-paderborn.de wrote:
> I have a big problem with file locking and threads under Linux.
> Before I start threads, I create a pid file which will be locked with fcntl.
> After killing the program (killall or Ctrl-C), the lock will not be
> removed always. When starting the program again, I get the error message,
> that pid <xxx> owns the lock, but there is no program running with this pid.
> 
> Any chance to fix this ? I need threads and file locking.

The problem is that the lock cannot be removed by another thread than the
one that created it (at least in 2.0.33).
Try to use flock in stead of fcntl. This worked for us (partially). Flock
does not check for the PID of the thread that tries to unlock the file.
There are some other problems with dangling locks with more than 2
threads, but I am not sure what causes this problem.

Hope this helps.
  Berend.

--

Berend Reitsma

  United Info B.V.         |  Phone: +31 (0)513 469100
  P.O. Box 10              |  Fax:   +31 (0)513 461588
  8408 ZH  Lippenhuizen    |  Email: berend@united-info.com
  The Netherlands          |  URL:   http://www.asset-control.com/

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic