[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [linux-team] /Perl/ fcntl (file-locking)
$unfichier="/etc/passwd";
open(MONDESC, "+< $unfichier";
flock(MONDESC,2) or die "locking impossible : $!";
close(MONDESC);
On Fri, 30 Jul 1999, Pascal Bleser wrote:
> Qqn a déjà utilisé fcntl (2) en Perl pour locker un fichier ?
> J'ai consulté le man pour bricoler un petit script de test:
> - - - - - - - - - - - - - - - - - - - - - -
> #!/usr/bin/perl
> use Fcntl;
> open(H, "foo") or die "Cannot open foo";
> fcntl(H, F_SETLK, $buffer) or die "$!";
> print "ok\n";
> close(H);
> 1;
> - - - - - - - - - - - - - - - - - - - - - -
> et ça me sort à chaque fois:
> Invalid argument at /home/pab/bin/lkfoo line 5.
> (c'est le die du fcntl)
> J'ai essayé de remplacer F_SETLK par F_GETLK, mais c pareil.
>
> J'ai bricolé un script perl qui réexpédie des mails NetWare
> par SMTP (hyper-facile ;)), mais j'aimerais bien ajouter un
> lock exclusif sur les fichiers pendant que le script
> travaille dessus.
> De toute manière, ça m'étonnerait que je puisse mettre un lock
> sur un fichier qui se trouve dans un répertoire NetWare monté.
> Mais bon... je voudrais bien essayer ;)
>
> --
> -o) Pascal Bleser |
> /\\ C++/UNIX Development | God is real, unless
> _\_v ATOS Payment Systems | declared integer.
> Aachen, Germany |
> <pbleser@atos-group.com>-------<guru@linuxbe.org>
>
> ---------
> 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.
>
----------------------------------------------------------
Alexandre J.D. Dulaunoy | Pmail : adulau@be.linux.org |
Tagged as unknown | Wmail : adulau@metatix.com |
_____________ (aka) AD993-RIPE/AD4384-DARPA ______________
"Anyone who attempts to generate random numbers by
deterministic means is, of course, living in a
state of sin." -- John von Neumann
----------------------------------------------------------
PGP keyID : 1024/4165497C | whois dulaunoy@rs.internic.net
----------------------------------------------------------
---------
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.