Reputation: 45
I'm building 2 programs (client/server) that communicate through FIFOs. Both programs have threads. When the Client's thread ends it doesn't get joined, and main hangs.
The programs do the following:
Server:
Client:
The server works well and all threads are joined accordingly.
The client fails in step 5. Using
pthread_join(&reader,NULL);
hangs main forever. I've checked, and the thread already ended.
Using
pthread_tryjoin_np(&reader,NULL);
I get
errorcode=16
strerror gives
Device or resource busy
Creating the thread with:
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_JOINABLE);
pthread_create(&reader,&attr,trataResp,NULL);
Or with: pthread_create(&reader,NULL,trataResp,NULL);
doesn't produce any change.
How can I resolve this?
Upvotes: 3
Views: 1217
Reputation: 17085
Well pthread_join receives the thread id, not the address for it. This line:
pthread_join(&reader,NULL);
Should be:
pthread_join(reader,NULL);
If reader
was declared as pthread_t
.
Hope it's not just a typo in your question and that this actually helps.
Upvotes: 4