On Jan 29 09:00, Steven Bardwell wrote: > My application needs several areas of shared memory, and I am getting an > error ("No such device") on the second call to mmap(). The first call works > fine. > > Here a simple program that shows the error (compiled with > gcc -o mmaptest mmaptest.c -lrt): > > #include <stdio.h> > #include <stdlib.h> > #include <string.h> > #include <sys/types.h> > #include <sys/errno.h> > #include <fcntl.h> > #include <sys/mman.h> > > int main() > { > int shm_fd1, shm_fd2; > char *mmap1, *mmap2; > /* get fd for each block of memory */ > shm_fd1 = shm_open("/block1", O_CREAT | O_RDWR, 0666); > if (shm_fd1 == -1) { > fprintf(stderr, "Couldn't get fd for block1 (%s)\n", > strerror(errno)); > exit(1); > } > shm_fd2 = shm_open("/block2", O_CREAT | O_RDWR, 0666); > if (shm_fd2 == -1) { > fprintf(stderr, "Couldn't get fd for /UNI_queue (%s)\n", > strerror(errno)); > exit(1); > } > /* map each block */ > mmap1 = mmap(NULL, 524304, PROT_WRITE | PROT_READ, MAP_SHARED, shm_fd1, > 0); > if (mmap1 == (char *)-1) { > fprintf(stderr, "Couldn't map memory for /block1 (%s)\n", > strerror(errno)); > exit(1); > } > mmap2 = mmap(NULL, 524304, PROT_WRITE | PROT_READ, MAP_SHARED, shm_fd2, > 0); > if (mmap2 == (char *)-1) { > fprintf(stderr, "Couldn't map memory for /block2 (%s)\n", > strerror(errno)); > exit(1); > } > fprintf(stdout, "Shared memory initialized\n"); > exit(0); > } > > The problem does not seem to depend on the size of the requested memory. The > program > always returns with "Couldn't map memory for /block2 (No such device)"
Try stracing it. I tried it on the latest Cygwin from CVS as well as on Cygwin 1.7.27 (32 bit versions) and it works fine for me. Your testcase is missing an ftruncate or two., btw. I guess you're aware of that and just dropped them to get a the simple testcase. Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat
pgp3G2jtAo4Mb.pgp
Description: PGP signature