B
Bedo Sandor
Hi All,
There are 3 different file locking mechanisms in C:
flock
lockf
fcntl
I want to write a Ruby script, which shares files with
a C program using all of these lockings.
As I can see objects with the type File have an flock
method. This is the only one I can use. There is an
fcntl method, but I don't know how to use it. What
kind of parameters can I pass to fcntl? I want to
implement this code in Ruby for fcntl:
def lock_fcntl(fd)
# struct flock f_lock;
# memset(&f_lock, '\0', sizeof(f_lock));
# f_lock.l_type = F_WRLCK;
# f_lock.l_whence = SEEK_SET;
# f_lock.l_start = 0;
# f_lock.l_len = 0;
# fcntl(fd, F_SETLKW, &f_lock);
end
and I need a lockf-type method too:
def lock_lockf(fd)
# ???
end
Could you show me how to use fcntl, and how to
access lockf from Ruby?
There are 3 different file locking mechanisms in C:
flock
lockf
fcntl
I want to write a Ruby script, which shares files with
a C program using all of these lockings.
As I can see objects with the type File have an flock
method. This is the only one I can use. There is an
fcntl method, but I don't know how to use it. What
kind of parameters can I pass to fcntl? I want to
implement this code in Ruby for fcntl:
def lock_fcntl(fd)
# struct flock f_lock;
# memset(&f_lock, '\0', sizeof(f_lock));
# f_lock.l_type = F_WRLCK;
# f_lock.l_whence = SEEK_SET;
# f_lock.l_start = 0;
# f_lock.l_len = 0;
# fcntl(fd, F_SETLKW, &f_lock);
end
and I need a lockf-type method too:
def lock_lockf(fd)
# ???
end
Could you show me how to use fcntl, and how to
access lockf from Ruby?