delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:date:from:to:subject:message-id:reply-to | |
:references:mime-version:content-type:in-reply-to; q=dns; s= | |
default; b=niT4WIwXwUlnkFN/ybehTSOSIDmOe/gtl5a2OGQTr1A2xqnrqq5A9 | |
7Hg5mWQPKgElSspXvnV2lUUtEagZG43nhTyKeb8O39FLvctw+6DyzwQcF2TaumjL | |
USwRB/kkgChr9JhauAeHUAvcwE9XHSYpQJbHC2V8xkXDWcA/yyQIGg= | |
DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:date:from:to:subject:message-id:reply-to | |
:references:mime-version:content-type:in-reply-to; s=default; | |
bh=hdngE98+bpyRaTpYdA4sm1Rp7Do=; b=R8NfcY+IGnkroBO6627F4cr3rcky | |
YkRF7CRoSStBzmwBlg1J2gVhTkVwJAKns1b+jggA+zjTSlKLRKu8ZfGFzfPtaJDU | |
K3R6qqF8UaJFuTLXkJ4hI1DqvaC5lbUn+zrNkro0sCUZ9aySBfICgNxbyekMp0OW | |
Hcs7v5RNBcNMROQ= | |
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 |
Authentication-Results: | sourceware.org; auth=none |
X-Virus-Found: | No |
X-Spam-SWARE-Status: | No, score=-6.0 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 |
X-HELO: | calimero.vinschen.de |
Date: | Wed, 29 Jan 2014 19:12:50 +0100 |
From: | Corinna Vinschen <corinna-cygwin AT cygwin DOT com> |
To: | cygwin AT cygwin DOT com |
Subject: | Re: second call to mmap() results in error |
Message-ID: | <20140129181250.GW2821@calimero.vinschen.de> |
Reply-To: | cygwin AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
References: | <01a801cf1cfa$77957900$66c06b00$@lbmsys.com> |
MIME-Version: | 1.0 |
In-Reply-To: | <01a801cf1cfa$77957900$66c06b00$@lbmsys.com> |
User-Agent: | Mutt/1.5.21 (2010-09-15) |
--Li7ckgedzMh1NgdW Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 wor= ks > fine. >=20 > Here a simple program that shows the error (compiled with > gcc -o mmaptest mmaptest.c -lrt): >=20 > #include <stdio.h> > #include <stdlib.h> > #include <string.h> > #include <sys/types.h> > #include <sys/errno.h> > #include <fcntl.h> > #include <sys/mman.h> >=20 > int main() > { > int shm_fd1, shm_fd2;=20=20=20=20=20=20=20=20=20 > char *mmap1, *mmap2; > /* get fd for each block of memory */ > shm_fd1 =3D shm_open("/block1", O_CREAT | O_RDWR, 0666); > if (shm_fd1 =3D=3D -1) { > fprintf(stderr, "Couldn't get fd for block1 (%s)\n", > strerror(errno)); > exit(1); > } > shm_fd2 =3D shm_open("/block2", O_CREAT | O_RDWR, 0666); > if (shm_fd2 =3D=3D -1) { > fprintf(stderr, "Couldn't get fd for /UNI_queue (%s)\n", > strerror(errno)); > exit(1); > } > /* map each block */ > mmap1 =3D mmap(NULL, 524304, PROT_WRITE | PROT_READ, MAP_SHARED, shm_fd= 1, > 0); > if (mmap1 =3D=3D (char *)-1) { > fprintf(stderr, "Couldn't map memory for /block1 (%s)\n", > strerror(errno)); > exit(1); > } > mmap2 =3D mmap(NULL, 524304, PROT_WRITE | PROT_READ, MAP_SHARED, shm_fd= 2, > 0); > if (mmap2 =3D=3D (char *)-1) { > fprintf(stderr, "Couldn't map memory for /block2 (%s)\n", > strerror(errno)); > exit(1); > } > fprintf(stdout, "Shared memory initialized\n"); > exit(0); > } >=20 > 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 --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --Li7ckgedzMh1NgdW Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJS6USiAAoJEPU2Bp2uRE+gSPQQAIwWSnLLS+NtTrVZTocJ9Uvb Q0MYhLkBW9JYXYv2ZrH3LNQ4mhk5fmerT+/4sLddo8TOCRc+p++7gtLs4TIgY9iI v4r+RGyxxDZCEMCdzEjmeFXGfatDfcAiFBXTL7DCIhAB4u9qrdyBV2mnckDGy93K ASXTMkCBs110pYyNk5fClvPSZnj2pu9Qeq83/mnS3rmhyGwE6Od2wLUffFOppW2x lvf2oc6QCu42/NgXmp+khUsHcTBns/rhKlFAQ6uvG7KtB2ZjuQhKAnUwI/CvvO9/ DwYfdZIY5QI3oZMFEEOWYrq/jLcyPLe/kx5Et+2O5waUY0vsljeNNMI8pmKFyLE3 tAgVPK4bJUkww0V2B1B1vuf15x5J4PaOgraZNZ3FC3cJ1NJ6UBwqiHaNCsd1XPET 6aCN5F2dqPbEtJrLVAaP6hQSrOJFhmKzwmkUP/XvwkuEvCHXJhKCGXBUq0feLdgI Q+cMXsmTu6GhTK0PTXefDnn70GNTLL+vKdtp4RBA/Ya6nFNEt/ZLdFNt/AgE4IF5 Ev11ixPorVTKQGKoAi99HmdK1M4XN0KSUawGK+yXWPGsfWYoD9BiiiTuKKLrJQ9/ Hrkrd1I1BBwD8P/2UOW4fxUY9oO7Uz/pEme8WlpmOtTJNYLjlV1OfjZ7wf+66Z3k fabfZGRTsuAJ9QkJQfYT =a871 -----END PGP SIGNATURE----- --Li7ckgedzMh1NgdW--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |