views:

56

answers:

1

I have one application which has several different threads. Then I forked with fork() but found the child process has to recreate those threads. Is that possible to copy the threads during the clone? Thanks!

+1  A: 

If you are using Unix, in C then the fork() should be creating all the new threads, if you are forking after the threads have been created, but this will lead to duplicating of using resources, so can be a problem.

http://gauss.ececs.uc.edu/Users/Franco/ForksThreads/forks.html

This article talks about a problem using fork in a multi-threaded application, and they reference a web page and the page is below: http://www.viraj.org/b2evolution/blogs/index.php/2007/02/10/threads_and_fork_a_bad_idea

http://www.lsgalilei.org/glibc-doc/Threads-and-Fork.html

This question should have the answers you need, btw: http://stackoverflow.com/questions/1073954/fork-and-existing-threads

James Black
Thanks a lot! I think I have the answer from you!
xis19
When you have the actual answer can you please post that as an update to your question, so that if someone else has the same type of problem it can help them.
James Black