title: C++ Linux named pipe hanging on open() with O_WRONLY
body: <p>This is my simple code that opens a named pipe, writes a string to it, and then closes the pipe. The pipe is created in a another function, as mentioned below. </p>
  
  <pre><code>char * ipcnm = "./jobqueue";
  
  std::cout &lt;&lt; "opening job queue" &lt;&lt; std::endl;
  
  //ensure the jobqueue is opened
  if ((jobq = open(ipcnm, O_WRONLY)) &lt; 0) {
    perror("open");
    exit(-1);
  }
  
  std::cout &lt;&lt; "queue opened" &lt;&lt; std::endl;
  
  // record the number of bytes written to the queue
  size_t written = write(jobq, ptr, size*nmemb);
  
  // close fifo
  if (close(jobq) &lt; 0) {
    perror("close");
    exit(-1);
  }
  
  // need to report to other agents the size of the job that was written
  jobSizes.push_back(written);
  </code></pre>
  
  <p>but the call to open() hangs. I've made sure that there is no other process using the fifo "jobqueue" at the time of calling and the file permissions for the queue once it's created are set prwxrwxr-x (I'm just using <code>mkfifo(ipcnm, 0777)</code> to create the pipe.</p>
  
  <p>I thought at first that it was a problem the that group <code>o</code> is missing <code>w</code> permissions on this pipe, so i manually changed them with chmod and it still hangs, as "queue opened" never gets printed. Nor does the error message for perror("open"); </p>
  
  <p>What am I missing?</p>