title: Closing file descriptor in multithreaded program
body: <p>I have a thread I made to accept incoming connections with:</p>
  
  <pre><code>pthread_t thread;
  
  pthread_create(&amp;thread, NULL, worker_func, NULL);
  pthread_detach(thread);
  </code></pre>
  
  <p>Then <code>worker_func</code> does:</p>
  
  <pre><code>&lt;snip&gt;
  fd = accept(GlobalFD, NULL, NULL);
  &lt;snip&gt;
  </code></pre>
  
  <p>However, If I try to close <code>GlobalFD</code> in my original thread, accept will still block (I want it to fail if GlobalFD is closed).  I've looked online and at other questions and can't seem to find the answer to my particular problem.</p>
  
  <p>Any ideas? 
  Thanks</p>