title: Processes hang on read
body: <p>The following code reads messages from other processes through a pipe. All processes correctly print out all the messages, but then they will never proceed past the while loop. Tried debugging in Eclipse, after reading reading all the messages, it will just stop at that while loop.</p>
  
  <p>The index is a number assigned to each process. The first process would have index == 0.
  The message itself is simply the index of the process sending the message.</p>
  
  <pre><code>while((n = read(fd[index][0], &amp;mymsg, sizeof(int))) == sizeof(int))
          printf("process%d  has received a message from process%d\n", index, mymsg);
  </code></pre>
  
  <p>Any ideas why this would happen?</p>
  
  <p>Here is how each process writes to another:</p>
  
  <pre><code>// Write to other process
  if(write(fd[index2][1], &amp;index, sizeof(int)) != sizeof(int))
      sys_error(2);
  </code></pre>
  
  <p>This is done five times. fd is a table of read-and-write ends for each process.</p>