file locking problem

BJ baj2107@columbia.edu
Thu Sep 20 00:05:00 GMT 2007


I have a file locking problem that is solved under Mac and Linux using
fcntl:
int lockRepFile (int fd, char lock, size_t from, size_t length) {
struct flock fl;

      fl.l_start = from;
      fl.l_len = length;
      fl.l_pid = 0;

      if (lock == 'r') fl.l_type = F_RDLCK;
      else if (lock == 'w')  fl.l_type = F_WRLCK;
      else if (lock == 'u')  fl.l_type = F_UNLCK;
      fl.l_whence = SEEK_SET;

      return (fcntl(fd, F_SETLKW, &fl));
}

Now, unfortunately this hangs occasionally using cygwin - gcc.

I would appreciate any comments and suggestions on how debug this and how to
improve the performance i.e. stop it from hanging...

Thanks

B







--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list