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

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu

\
 
 \ /
  Last update: 2005-03-22 13:41    [W:0.051 / U:0.444 seconds]
©2003-2014 Jasper Spaans. Advertise on this site