This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

fcntl() bug? if called second times!


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@HEIKO ~/src/fslock
    $ ./fslocktest
    Lock 1
    Lock 2
    lock failed: fslocktest.txt: Permission denied

===> linux console
    heiko@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.elger.spam@gmx.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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]