From: "Bermejo, Rodrigo" Date: 2003-07-16T03:49:28+09:00 Subject: Re: file locking have you checked it 'http://raa.ruby-lang.org/list.rhtml?name=filelock' out -r. Bedo Sandor wrote: > > 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? > > > -- General Electric - CIAT Advanced Engineering Center ________________________________________ Rodrigo Bermejo Information Technologies. Dial-comm : *879-0644 Phone :(+52) 442-196-0644 mailto:rodrigo.bermejo@ps.ge.com