VC++ 6.0 : pthread_join is hanging  (Linux to Windows porting)

Posted on 2006-06-02
Medium Priority
Last Modified: 2013-11-15

OS : Windows XP
Compiler : VC++ 6.0
pthreads library : http://sources.redhat.com/pthreads-win32/

In the following sample program, pthread_join is hanging in Windows and same is working in Linux.

Could u please explain why pthread_join is hanging here though the cancellation point is enabled.

What are all the possible causes for pthread_join to hang ?


// Thread Creation -- finish the job -- and Join thread to the main thread
Sdf_fn_createThread (&(this->dnsProcessResultsThreadId), Sdf_co_null,                                                                                       dnsResultProcessorThread,\
                                        (void*)this, &error));

pthread_join(this->dnsProcessResultsThreadId, &pExitCode); // Hanging ?


void* dnsResultProcessorThread ( void *pData) // Actual Job of the thread
      fdset      read_fds, write_fds;
      int nfds,count;
      timeVal *tvp,tv;
      /* Cancel enable the thread */
      pthread_setcancelstate(Sdf_mc_cancelEnable, Sdf_co_null);
      while (1)
            /* Check if the thread is cancelled */      

            /* wait for arrival of data , or a timeout to occur*/
            count = select(nfds, &read_fds, &write_fds, NULL, tvp);

            if (count < 0 && errno != EINVAL)
                           // Error Handling

            if(FD_ISSET(pLookupDns->sockfd, &read_fds) != 0)
                  /* Indicates that a new query is made.*/
                  FD_CLR(pLookupDns->sockfd, &read_fds);
                  char buf[9];
                  count = recv(pLookupDns->sockfd,buf,9,0);
      return NULL;
Question by:k_kalyan
1 Comment
LVL 48

Accepted Solution

AlexFM earned 1000 total points
ID: 16822314
There are number of calls inside of thread: select, recv, FD_CLR etc. Are these calls blocking? When thread must exit, every call inside of this thread should return immediately.

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here in this article, you will get a step by step guidance on how to restore an Exchange database to a recovery database. Get a brief on Recovery Database and how it can be used to restore Exchange database in this section!
Today as you open your Outlook, you witness an error message: “Outlook is using an old copy of your Outlook Data File…”. Probably, Outlook is accessing an old OST file.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question