Chung Kil Kim wrote:
> I insert following line before first fcntl call
> lock_info.l_type = F_UNLCK
>
> but same error message print out.
Yes, because you are still not using it correctly.
> I reedit the code like this
> ...
> memset (&lock_info, 0, sizeof (lock_info));
> while (1)
> {
> ...
>
> Now no error message is print out.
> I guess lock_info struct must be clear(all member) before call fcntl() function
> or lock_info get garbage value that is not proper to call fcntl().
No. lock_info must contain a valid description of a lock, just as with
F_SETLK. Setting it's contents to zero is equivalent to the following:
lock_info.l_type = F_RDLCK;
lock_info.l_whence = SEEK_SET;
lock_info.l_start = 0;
lock_info.l_len = 0;
lock_info.l_pid = 0;
So, you are basically testing whether you can create a read lock on a
range covering the entire file (if l_len is zero it means `all of
remaining bytes in the file').
> Why function fcntl so sensitive?
It isn't. You are not using it correctly.
--
Glynn Clements <[EMAIL PROTECTED]>