title: Does pthread_cancel works if the thread is running blocking code like accept connection?
body: <p>I am <strong>beginner</strong> to C programming I created a new thread and its working fine ,my thread blocks the code at <strong>accept</strong>.Does calling <strong>pthread_cancel</strong> from outside terminates the thread.Or do I need to <strong>close the socket</strong> from outside.</p>
  
  <p>Inside thread code it is a blocking code </p>
  
  <pre><code> while( (clientfd = accept(socketfd, (struct sockaddr *)&amp;client,&amp;clilen)) )
          {
                  printf("New Client connected");
                  ......
          }
  </code></pre>
  
  <p>Calling <strong>pthread_cancel</strong> from outside</p>
  
  <pre><code>pthread_cancel(thread_id);
  </code></pre>
  
  <p>What happens?</p>