title: Handle a signal as error
body: <p>Hi I'm programming a threaded socket program, The program may receive a <code>SIGPIPE</code> signal and will exit, If I catch the signal and ignore it the program will have undefined behavior because I don't know how to handle this as error, How can I catch a signal and notify the current position of the code that it needs to return from a function with error code so the program flow will continue as normal, I want to threat the <code>SIGPIPE</code> as it is error in read/write syscalls, cause i know how to handle read/write errors when I receive them. </p>
  
  <pre><code>{
      signal(SIGPIPE,sig_handler);
  }
  
  void sig_handler(int signo)
  {
    if (signo == SIGPIPE){
      printf("hi\n");
  
    }
  }
  </code></pre>