<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: second call to shmat in same process in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/second-call-to-shmat-in-same-process/m-p/5088406#M441908</link>
    <description>Closing thread.</description>
    <pubDate>Fri, 18 Jan 2008 04:04:01 GMT</pubDate>
    <dc:creator>pramodsharma</dc:creator>
    <dc:date>2008-01-18T04:04:01Z</dc:date>
    <item>
      <title>second call to shmat in same process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/second-call-to-shmat-in-same-process/m-p/5088404#M441906</link>
      <description>If the calling process is already attached to the shared memory  segment, shmat() fails and returns SHM_FAILED regardless of what value  is passed in shmaddr. &lt;BR /&gt;&lt;BR /&gt;This is not done in other *NIX platforms. &lt;BR /&gt;&lt;BR /&gt;Is there any mechanism to know this is already attached by someone in the process and if yes how to know the address to which it is attached , so that I can use it.&lt;BR /&gt;&lt;BR /&gt;I really don't want to make shared memory point global now. &lt;BR /&gt;&lt;BR /&gt;#include &lt;SYS&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt; #include &lt;SYS&gt;&lt;BR /&gt;#include &lt;FCNTL.H&gt;&lt;BR /&gt;extern int errno ;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;int main()&lt;BR /&gt;{&lt;BR /&gt;        int id  = -1 , id2;&lt;BR /&gt;        key_t key = ftok("/PRAMODTEST" , 700);&lt;BR /&gt;        id = shmget(key , 16 , 0600 | IPC_CREAT);&lt;BR /&gt;&lt;BR /&gt;        if( -1 != id)&lt;BR /&gt;        {&lt;BR /&gt;                void *sharedMem = shmat( id ,NULL ,SHM_RDONLY) ;&lt;BR /&gt;                if((int)sharedMem == -1 )&lt;BR /&gt;                {&lt;BR /&gt;                        printf("Attaching failed %d , %s \n" , errno , strerror(errno) );&lt;BR /&gt;                }&lt;BR /&gt;                else&lt;BR /&gt;                {&lt;BR /&gt;                        void *p = shmat(id ,NULL ,0) ;&lt;BR /&gt;                        if((int)p == -1 )&lt;BR /&gt;                        {&lt;BR /&gt;                                printf("Second attach is failed %d , %s \n" , errno , strerror(errno));&lt;BR /&gt;                        }&lt;BR /&gt;                        else&lt;BR /&gt;                        {&lt;BR /&gt;                                printf("Second attach paased\n");&lt;BR /&gt;                                shm_unlink("/PRAMODTEST");&lt;BR /&gt;                        }&lt;BR /&gt;&lt;BR /&gt;                        shmdt(sharedMem);&lt;BR /&gt;                }&lt;BR /&gt;        }&lt;BR /&gt;        else&lt;BR /&gt;                printf("shmget failde\n");&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;BR /&gt;&lt;BR /&gt;&lt;/FCNTL.H&gt;&lt;/SYS&gt;&lt;/STDIO.H&gt;&lt;/SYS&gt;</description>
      <pubDate>Thu, 17 Jan 2008 09:45:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/second-call-to-shmat-in-same-process/m-p/5088404#M441906</guid>
      <dc:creator>pramodsharma</dc:creator>
      <dc:date>2008-01-17T09:45:26Z</dc:date>
    </item>
    <item>
      <title>Re: second call to shmat in same process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/second-call-to-shmat-in-same-process/m-p/5088405#M441907</link>
      <description>Yes, that's in the man page and all:&lt;BR /&gt;&lt;BR /&gt;"If the calling process is already attached to the shared memory segment, shmat() fails and returns SHM_FAILED regardless of what value is passed in shmaddr. See exceptions for MPAS processes below."&lt;BR /&gt;&lt;BR /&gt;Quickly skimming over the gory details, this differs from other OS's because HP-UX is a Mostly Global Address Space, they're Mostly (or Completely) Private. And that's because PA doesn't allow (easily) multiple virtual addresses at the same time for the same physical memory (aliasing).&lt;BR /&gt;&lt;BR /&gt;Keep track of things within your own process (as you've considered and which I really think is the best option) or restrict yourself to 11iv2 and higher, IPF only and use MPAS (keeping in mind that using MPAS too much and generating a _lot_ of aliases slows down the system as a whole [because of the collision chains in the translation tables]).</description>
      <pubDate>Thu, 17 Jan 2008 12:02:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/second-call-to-shmat-in-same-process/m-p/5088405#M441907</guid>
      <dc:creator>Don Morris_1</dc:creator>
      <dc:date>2008-01-17T12:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: second call to shmat in same process</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/second-call-to-shmat-in-same-process/m-p/5088406#M441908</link>
      <description>Closing thread.</description>
      <pubDate>Fri, 18 Jan 2008 04:04:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/second-call-to-shmat-in-same-process/m-p/5088406#M441908</guid>
      <dc:creator>pramodsharma</dc:creator>
      <dc:date>2008-01-18T04:04:01Z</dc:date>
    </item>
  </channel>
</rss>

