title: Using signals and sigpipe
body: <p>I'm working on an assignment that involves writing a program to process data (calculate pi) using fork (processes), signals and select.</p>
  
  <p>I'm working right now on the signals and what I think I want to do is to use SIGPIPE so if the  programs catches it, it tries to write to the pipe again (If a process tries to write to a pipe that has no reader, it will be sent the SIGPIPE).</p>
  
  <p>I use fork() in main() to assign each process the same work by sending them to the worker function.</p>
  
  <pre><code>void worker(int id) {
      .... (this piece of code is not relevant)
  
      if(write(pfd[id][1], &amp;c, sizeof(c)) == -1)
          printf("Error occurred: %s\n",strerror(errno));
  
  }
  </code></pre>
  
  <p>How can I implement signals in this function to catch SIGPIPE and make it write to the pipe again?</p>
  
  <p>Thank you!</p>