title: pselect() with accept() in a loop
body: <p>I have a multi-threaded server, which spawns new threads with these loop:</p>
  
  <pre><code> while(handle-&gt;m_run) {
      if (handle-&gt;m_curThreadCount &lt; handle-&gt;m_maxThreads) {
        ready = pselect(socket + 1, &amp;readSocket, NULL, NULL, &amp;timeout, NULL);
        if (ready != 1)
          continue;
        DWORD openedSocket = accept(socket, NULL, NULL);
        handle-&gt;m_threads.emplace_back(std::thread(serverThread, openedSocket, handle));
        handle-&gt;m_curThreadCount++;
      }
    }
  </code></pre>
  
  <p>Most of the time this works as intended, but occasionally pselect() doesn't fire. I checked it with tcpdump and know, that data is sent to server, so I think it has something to do with main loop. </p>
  
  <p>Also, if run with gdb and broken on pselect() before sending data, pselect() returns 1 as intended.</p>
  
  <p>Is there something wrong with using pselect() this way and how should I fix this?</p>