Hi,
        you can use open system call itself to hold a lock on a file as
open(filename, O_RDONLY | O_EXCL). You can use flock to do the same.
Another way is to use fcntl system call to lock an already open file.
Refer to man pages of open, fcntl and flock. For your information
file locking was introduced in Unix (obviously in Linux also) long
back. Refer to Linux Programmers Guide. Good Luck.

-Shashidhar

On Wed, 1 Mar 2000, G A Abhay wrote:

> Is there any lock function (in C) to lock files on a linux machine
> Does the kernel provide such system calls at all?
> This should prevent other processes from accessing the same file.
> 
> abhay
> 
> 
> 
> --------------------------------------------------------------------------
> LI is all for free speech, but this list was created for a purpose --
> to help popularise Linux in India. If your messages are counterproductive
> to that purpose, your privileges to submit messages can and will be revoked.
> 


--------------------------------------------------------------------------
LI is all for free speech, but this list was created for a purpose --
to help popularise Linux in India. If your messages are counterproductive
to that purpose, your privileges to submit messages can and will be revoked.

Reply via email to