Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com From: "Heiko Elger" To: Cc: "ente59" Subject: fcntl() bug? if called second times! Date: Mon, 13 Jan 2003 18:00:34 +0100 Message-ID: <000701c2bb25$4d257640$0502a8c0@heiko> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" X-Priority: 3 (Normal) X-MSMail-Priority: Normal Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Sender: 320068521952-0001 AT t-dialin DOT net Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id h0DH2Gv16763 Hello, I try to comiple an run the distcc package - but I get errors while running. I figured out, tha the problems are the fcntl() calls - perhaps ther is a bug in cygwin? The following code runs differently in cygwin and linux. If I want ro lock the whole file twice, but still the same process, I will get an "permission denied" error on cygwin. The same code works on linux! ===> Cygwin console heiko AT HEIKO ~/src/fslock $ ./fslocktest Lock 1 Lock 2 lock failed: fslocktest.txt: Permission denied ===> linux console heiko AT linux:~/src/fslock> ./fslocktest Lock 1 Lock 2 Below is the code to reproduce the error. I'm using the following software: - Windows XP Professional Ver 5.1 Build 2600 Service Pack 1 CYGWIN=ntsec - Cygwin DLL version info: DLL version: 1.3.18 DLL epoch: 19 DLL bad signal mask: 19005 DLL old termios: 5 DLL malloc env: 28 API major: 0 API minor: 69 Shared data: 3 DLL identifier: cygwin1 Mount registry: 2 Cygnus registry name: Cygnus Solutions Cygwin registry name: Cygwin Program options name: Program Options Cygwin mount registry name: mounts v2 Cygdrive flags: cygdrive flags Cygdrive prefix: cygdrive prefix Cygdrive default prefix: Build date: Wed Dec 25 15:37:50 EST 2002 Shared id: cygwin1S3 - Linux: Suse 8.1 Perhaps someone can give me a hint ... Best regards Heiko Elger ------------ snip - snip - snip -------------------- /* make CFLAGS="-Wall -g -O0" testfcntl.c */ int main(int argc, char** argv, char** envp) { int fd ; char* fname = "fslocktest.txt"; int rc; struct flock lockparam; lockparam.l_type = F_WRLCK; lockparam.l_whence = SEEK_SET; lockparam.l_start = 0; lockparam.l_len = 0; /* whole file */ fd = open(fname, O_WRONLY|O_CREAT, 0600); if (fd == -1 && errno != EEXIST) { printf("failed to creat %s: %s", fname, strerror(errno)); return errno; } printf("Lock 1\n"); rc = fcntl(fd, F_SETLK, &lockparam); if (rc==-1) { printf("lock failed: %s: %s", fname, strerror(errno)); return errno; } printf("Lock 2\n"); rc = fcntl(fd, F_SETLK, &lockparam); if (rc==-1) { printf("lock failed: %s: %s", fname, strerror(errno)); return errno; } close(fd); return 0; } ------------ snip - snip - snip -------------------- Heiko Elger ,,, (o o) +------------------------oOO--(_)--OOo----------------------------+ | | | Email: heiko DOT elger DOT spam AT gmx DOT de | | | | bitte .spam in der Email-Adresse entfernen | | please remove .spam | | | | .oo0O O0oo. | | ( ) ( ) | +-------------------------\ (-----) /-----------------------------+ \_) (_/ -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Bug reporting: http://cygwin.com/bugs.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/