delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2007/09/19/20:05:30

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
To: cygwin AT cygwin DOT com
From: "BJ" <baj2107 AT columbia DOT edu>
Subject: file locking problem
Date: Wed, 19 Sep 2007 19:30:26 -0400
Lines: 30
Message-ID: <fcsbji$bj0$1@sea.gmane.org>
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019