[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ProgSoc] POSIX pthreads
It's been a little while since I used POSIX threads, but are you waiting
for the threads to finish once you have created them? I can't quite
remember if this is the way it werks, but if the main() function ends
without issuing a pthread_join() call, the whole process will end
including all threads. But since you are detaching the threads this won't
work. Something to think about tho.
Try exiting normally from the start function of the thread (with a return
call) rather than an explicit pthread_exit perhaps.
> The main thread in the server creates a separate thread using
> pthread_create() for each request that arrives. The very first thing a new
> thread does is to detach itself using pthread_detach().
> When the new thread has finished processing the request it terminates
> itself using pthread_exit(). I only want this particular thread to exit,
> but unfortunately, it looks like the whole server (i.e. all threads) exit
> when pthread_exit() is called.
> I was under the belief that when a "detached" thread exited, it didn't
> cause any other threads in the same process to exit. Is this correct?
> Where am I going wrong?
> Greg Kopff
> email@example.com PowerSource Software
> Do you know that 'if' is the middle word in life?
> You are subscribed to the progsoc mailing list. To unsubscribe, send a
> message containing "unsubscribe" to firstname.lastname@example.org.
> If you are having trouble, ask email@example.com for help.
Don't worry over what other people are thinking about you. They're too
busy worrying over what you are thinking about them.
You are subscribed to the progsoc mailing list. To unsubscribe, send a
message containing "unsubscribe" to firstname.lastname@example.org.
If you are having trouble, ask email@example.com for help.