Using fcntl for locking 
Author Message
 Using fcntl for locking

Hi,

I need to lock a file over NFS. Can fcntl do that, and how do I use it?
Particularly, what does the third argument have to be?

Cheers,
Paris



Wed, 18 Jun 1902 08:00:00 GMT  
 Using fcntl for locking

Quote:
> Hi,

> I need to lock a file over NFS. Can fcntl do that, and how do I use it?
> Particularly, what does the third argument have to be?

You are probably better off reading the fcntl(2) manpage in the first place
where it describes the releveant constants - these will be defined in
the module Fcntl ...

/J\
--
"If I was going to wear a wig I'd choose something a lot better than this"
- Barry Norman



Wed, 18 Jun 1902 08:00:00 GMT  
 Using fcntl for locking

Quote:


> > Hi,

> > I need to lock a file over NFS. Can fcntl do that, and how do I use it?
> > Particularly, what does the third argument have to be?

> You are probably better off reading the fcntl(2) manpage in the first place
> where it describes the releveant constants - these will be defined in
> the module Fcntl ...

Actually I already have.  But my question remains: what I am supposed to give
as the third argument ("pointer to a struct flock")?

Paris



Wed, 18 Jun 1902 08:00:00 GMT  
 Using fcntl for locking

Quote:


>> > Hi,

>> > I need to lock a file over NFS. Can fcntl do that, and how do I use it?
>> > Particularly, what does the third argument have to be?

>> You are probably better off reading the fcntl(2) manpage in the first place
>> where it describes the releveant constants - these will be defined in
>> the module Fcntl ...

> Actually I already have.  But my question remains: what I am supposed to give
> as the third argument ("pointer to a struct flock")?

A scalar containing the packed data that would consitute that structure :

     short l_type;   /* F_RDLCK, F_WRLCK, F_UNLCK */
     short l_whence; /* flag for starting offset */
     long l_start;   /* relative offset in bytes */
     long l_len;     /* if 0 then until EOF */
     short l_pid;    /* returned with F_GETLK */

so you might have something like :

use Fcntl(:DEFAULT :flock);

my $struct_flock = pack "SSLLS",F_WRLCK,0,0,0,0;

<etc>

/J\
--
"Shhh! They're strapping down Liza Minelli" - Lisa Simpson



Wed, 18 Jun 1902 08:00:00 GMT  
 Using fcntl for locking
On Sun, 16 Jan 2000 14:05:58 +0000,

Quote:
>Hi,

>I need to lock a file over NFS. Can fcntl do that, and how do I use it?
>Particularly, what does the third argument have to be?

File locking can be unreliable and sometimes not supported in a NFS
environment.

Maby this can be elaborated on comp.protocols.nfs.

Villy



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Help with using fcntl file locking

2. Trouble using fcntl to lock file

3. Has anyone used Fcntl to handle file locking?

4. Req for example: file lock using fcntl

5. File locking using Fcntl

6. Nee file lock example using fcntl

7. Need example of file locking using fcntl

8. File locking with fcntl()

9. Still locks, with fcntl

10. problem locking file with fcntl (HP-UX)

11. File locking via 'fcntl()'

12. Fcntl locking and NFS.

 

 
Powered by phpBB® Forum Software