Multithreaded fork

后端 未结 3 905
逝去的感伤
逝去的感伤 2020-12-03 13:45

Can fork() function be used to replicate a multithreaded process. And if so, will all threads be exactly the same and if not, why not. If replication can\'t be done through

3条回答
  •  [愿得一人]
    2020-12-03 14:19

    No, the child will only have one thread. Forking a threaded process is not trivial. (See this article Threads and fork(): think twice before mixing them for a good rundown).

    I don't know of any way of cloning a process and all its threads, I don't think that's possible on Linux.

提交回复
热议问题