title: named pipes permission bits
body: <p>I am writing a simple C program to exchange messages
  through named pipes on linux. The problem is I have
  to run it as superuser to make it work, otherwise i get:
  "Permission denied" error.
  Write permission on the directory is granted:</p>
  
  <pre><code>drwxr-xr-x 2 alpa alpa  4096 26 giu 17.24 .
  </code></pre>
  
  <p>Umask should be ok:</p>
  
  <pre><code>$ umask
  0022
  </code></pre>
  
  <p>The pipe file is actually created, but with <strong>wrong</strong> permissions bits:</p>
  
  <pre><code>$ ls -l | grep fifo.fifo
  pr----x--t 1 alpa alpa     0 26 giu 17.29 fifo.fifo
  </code></pre>
  
  <p>So when I try to open it for reading or writing the
  open() system call fails.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>...
  if(mkfifo(pathname, perms) == -1 &amp;&amp; errno != EEXIST)
    return NULL;
  if(chmod(pathname, perms) == -1)
      return NULL;
  ...
  fifo-&gt;fd[0]= open(fifo-&gt;pathname, O_RDONLY);
   if(fifo-&gt;fd[0] == -1){
  fifo_delete(&amp;fifo);
    return NULL;
  ...
  </code></pre>
  
  <p>Thank you in advance for your help.</p>