title: Compiler error (invalid conversion from ‘void (*)()’ to ‘__sighandler_t {aka void (*)) in writing signal handler
body: <p>I wrote a program which reads from a named pipe and after five reads it prints what it read in last five times. I want to write a <code>SIGTERM Handler</code> for cleaning up the queue at shutdown. But when I write the handler g++ gave me this error:</p>
  
  <blockquote>
    <p>invalid conversion from ‘void (<em>)()’ to ‘__sighandler_t {aka void (</em>)(int)}</p>
  </blockquote>
  
  <pre><code>queue&lt;string&gt; q;
  void cleanup(){
      while(!q.empty()){
          cout&lt;&lt;q.front()&lt;&lt;endl;
          q.pop();
      }
  }
  int main(){ 
      signal(SIGTERM, cleanup);
      int fd = open("named-pipe", O_RDONLY, 0);
      char readbuf[80];
      while(1){
          int n=read(fd, &amp;readbuf, sizeof(readbuf));
          readbuf[n]=0;
          q.push(string(readbuf));
          if(q.size()&gt;=5)
              while(!q.empty()){
                  cout&lt;&lt;q.front()&lt;&lt;endl;
                  q.pop();
              }
      }
  }
  </code></pre>