[lkml]   [1998]   [Feb]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: threads and file locking doesn't work correct
    On Tue, 24 Feb 1998 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 Reitsma

    United Info B.V. | Phone: +31 (0)513 469100
    P.O. Box 10 | Fax: +31 (0)513 461588
    8408 ZH Lippenhuizen | Email:
    The Netherlands | URL:

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to

     \ /
      Last update: 2005-03-22 13:41    [W:0.018 / U:1.220 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site