title: Why am I denied permission trying to shm_open?
body: <p>Consider the following C program:</p>
  <pre class="lang-c prettyprint-override"><code>#include &lt;stdio.h&gt;
  #include &lt;fcntl.h&gt;
  #include &lt;sys/mman.h&gt;
  #include &lt;errno.h&gt;
  #include &lt;sys/types.h&gt;
  #include &lt;string.h&gt;
  
  int main() {
      const char* name = &quot;/memmap_ipc_shm&quot;;
      int shmFd = shm_open(name, O_RDWR | O_CREAT, 0777);
      if (shmFd &lt; 0) {
          fprintf(stderr,&quot;bad shmfd opening %s: %s\n&quot;, name, strerror(errno));
          return -1;
      }
      return 0;
  }
  </code></pre>
  <p>When I run it on my GNU/Linux system (Devuan Beowulf, Linux 5.10.0-9, amd64 CPU), I get:</p>
  <pre><code>bad shmfd opening /memmap_ipc_shm: Permission denied
  </code></pre>
  <p>Why am I denied permission? I'm pretty sure I followed all the guidelines in the <code>man shm_open</code> page, my requested permissions seem ok - so what's wrong?</p>