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=quqmxv0UiBv742K+NwlF+q3Cm2eRBazkeF9tv+/917glfe3SDjKnC vOd1wxwOxrLE13VMtvu9UOGMQddn8dzQVs4cP1+vJKzzq+FxiL81I0FJbyVi4ta9 yWYnz+QR0R8prQoWSczgTP81SHahEsVdYAusFUQk8SNBGvPb+kfA2A= 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=hogUQArk5Z2mR7WfVEPIQgGf4/Y=; b=J0vOgnCqZFBQpAusdcD5PlshFyGw lo8JIKFO8psFLgjxNe/t0XoDaMoQJG9bRbnrVE0iMyyQY4BuLtHZw0AbbptXvXN5 yULG4KUWq/O6DLdS4Sz/xhzcaDGw1zY5ogBgFLdDP/T098PZSbJsLLOg2Q9ZOgmU HYY2Acm8CVTSZhs= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: 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 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.4 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,UNSUBSCRIBE_BODY autolearn=no version=3.3.2 X-HELO: calimero.vinschen.de Date: Sun, 12 Apr 2015 13:23:25 +0200 From: Corinna Vinschen To: cygwin AT cygwin DOT com Subject: Re: Shared memory handling for mixed C/FORTRAN program Message-ID: <20150412112325.GP7343@calimero.vinschen.de> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <1999567694 DOT 2259208 DOT 1428493743005 DOT JavaMail DOT yahoo AT mail DOT yahoo DOT com> <1457851220 DOT 1207684 DOT 1428783910446 DOT JavaMail DOT yahoo AT mail DOT yahoo DOT com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="fNagykWcDoSVAmSd" Content-Disposition: inline In-Reply-To: <1457851220.1207684.1428783910446.JavaMail.yahoo@mail.yahoo.com> User-Agent: Mutt/1.5.23 (2014-03-12) --fNagykWcDoSVAmSd Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Apr 11 20:25, Christoph Weise wrote: > Please see below, I provide minimal C code for three separate > executables, one creates the shm section, another finds it, the third > removes it. I include also a bash test script that executes the > routines in order. Thanks, > Please beware as I removed some checks to reduce > the length of the code, but it should run ok. The PAGESIZE parameter > is hardcoded (here 512 bytes). The desired shared mem section size is > set interactively as input to makeshm, or automatically with the bash > script.=20 Ok, but there are bugs in the code which result in GCC warnings. I don't know which of them are part of your original code, but they are really a problem. if ((int) -1 =3D=3D p) Don't check a pointer against an int value. It won't work on a 64 bit platform. Make that if ((void *) -1 =3D=3D p) For the same reason, don't use %x to printf a pointer. Use %tx. > I can write to the shm section with the second routine when the requested= section <=3D 4096 bytes. Otherwise it's not happy.=20 The problem is the call to shmget: #undef PAGESIZE #define PAGESIZE 512 shmid =3D shmget(key, PAGESIZE, IPC_ALLOC); Since you're requesting only 512 bytes, the shared memory segment the following shmat call returns is only 4K. The shmget call should request as much memory as it needs so that the OS call is called with the right view size. I re-read the POSIX man page for shmget, and it doesn't mention anything which would point out that Cygwin's behaviour here is wrong. If anybody has more information on this, please share them. HTH, Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --fNagykWcDoSVAmSd Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBAgAGBQJVKlWtAAoJEPU2Bp2uRE+g9W8P/iw03gr/Ce1rC/uiJAIj5RvH L4jTtadTH6YgzB10pcR9dwzQOZeOomqGplk/WJUIKEvJPL5Da2OyscWkQxMhXNwn NB3welLM8S0AN8uLLYCyPrEdLQ4SUJaq3I/N3wYK9Ea/GgK5ZJdEFgoQ7+uhoh5E C/WahKaoZIo0JZOrlnZypZ8ce8KQGNlr60nY0poFrZ5ivCNh7l743cwquL0KCTLb aL94iGMTKeIMjP43XTyCjmB04fAR6/gV224+IhUchrgQWNF40CMzfqk1oaRCXchu BeusA/uZFsVTP3P5Rx0kTvtIBd+Qnh71NywZ5bRjk2g4zBL4I/l22FzOyLI/N831 TJUFnpXCXZdz8hx8aTw4Pmd1r9Sz8dIV5EhMQSUmsa9s2RgApeu05FwIgLi5s3Nw 5xo3mxKqT10YkyTLc+xfSwo8lNwfuvg3nUNzMUcv5z32ZxqSxES54G8mdGfg7DpF uzMxw1Y0zmCsV/K9seOyEM3DJoDxQqYCeO9UP+p5ieI5Kyforgmj+3whEI7orOS6 4+QZ4T97OYtQ0ZPx4kG+xluCnrNuovrvgeVS8BMaGcfidDrLxBZjz925+CcdzE25 neKP/87VB8x2F8vpJi1cpsk+rPu6VJzl03ZJas8hGImHBewBx+HJ0GLgCON46r8P CLR1bg+LL4mzgtXpyc7d =NxQS -----END PGP SIGNATURE----- --fNagykWcDoSVAmSd--