[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ProgSoc] POSIX pthreads
> Hi!
Howdy!
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?
>
> Thanks!
>
>
> Greg Kopff
> ===================================================
> gkopff@nospam.powersource.com.au PowerSource Software
> http://www.powersource.com.au
> 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 progsoc-request@nospam.progsoc.uts.edu.au.
> If you are having trouble, ask owner-progsoc@nospam.progsoc.uts.edu.au for help.
>
vik
vik4@nospam.mindless.com
<http://www.progsoc.org/~vik>
PGP: <http://www.progsoc.org/~vik/pgp.txt>
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 progsoc-request@nospam.progsoc.uts.edu.au.
If you are having trouble, ask owner-progsoc@nospam.progsoc.uts.edu.au for help.