Restarting threads in forked process Restarting threads in forked process multithreading multithreading

Restarting threads in forked process


Threads execution state is not only the data in stack. It is also set of CPU registers, which is lost.

do_fork() system call just don't copy any thread other from thread, which executes a syscall do_fork -> copy_process and there is a single call to copy_thread at line 1181

retval = copy_thread(clone_flags, stack_start, stack_size, p, regs);


Guess What? Solaris already has such a function by the name of forkall! Would love to see a port of it in Linux!


I guess you are talking about continuations. I saw some hits on google (I asked for "continuation c"), but I can't recomend any link, since I don't know your specific needs.