views:

83

answers:

1

When I use pthread_exit() in the initial thread, the initial thread switches in the terminated state. But I did not understand about the process.

Can exist a running process with the initial thread in the termitated state?

+3  A: 

In pthreads, as long as any thread is running, the process will stay alive.

So yes, you can have a running process even though the initial thread has exited.

One thing that may be confusing you is what happens when the initial thread returns from main(). This is the equivalent of calling exit(). So if main() returns, your process will end. But if the initial thread calls pthread_exit() and there are other threads still alive, your process will remain alive.

R Samuel Klatchko