[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [linux-team] /Perl/ fcntl (file-locking)



On Fri, Jul 30, 1999 at 05:09:42PM +0200, Alexandre Dulaunoy wrote:
> $unfichier="/etc/passwd";
> open(MONDESC, "+< $unfichier";
> flock(MONDESC,2) or die "locking impossible : $!";
> close(MONDESC);

aaah, que nenni ;)
flock != fcntl(..., F_SETLK, ...) !!!
flock ne met qu'un "advisory lock", càd que ça n'empêche pas un autre
processus d'accéder au fichier. L'autre processus doit vérifier si
il y a un lock et s'abstenir, mais si il ne le fait pas, rien ne
l'empêche d'écrire dans le fichier !!!
Les locks posés avec fcntl sont des "mandatory locks", càd que c'est
un vrai lock gèré par le système...

-- 
  -o) / Pascal Bleser          ATOS Payment Systems|
  /\\ \ C++/UNIX Development        Aachen, Germany|
 _\_v  \<guru@linuxbe.org> <pbleser@atos-group.com>|
---------------------------------------------------|
Shaw's Principle:                                  :
 Build a system that even a fool can use, and only :
 a fool will want to use it.                       :
---------------------------------------------------'

---------
Visit the Linux Supertore Online: http://www.redcorp.com !
If you want to be deleted from the list, send a mail to
majordomo@rtfm.be with "unsubscribe linux-team" in the body.