【问题标题】:Is there a way to spawn a new process without terminating the other threads?有没有办法在不终止其他线程的情况下产生一个新进程?
【发布时间】:2013-08-29 17:05:01
【问题描述】:

我正在 Linux 上编写多线程程序,并希望在一个线程中创建一个进程而不结束其他线程。我查看了 fork/exec,但在 linux 上第 3p 部分的 exec 手册页中:

 A call to any exec function from a process with more  than  one  thread
 shall  result  in  all  threads being terminated and the new executable
 image being loaded and  executed.  No  destructor  functions  shall  be
 called.

有没有办法在不终止其他线程的情况下生成一个新进程?

【问题讨论】:

    标签: c linux pthreads exec


    【解决方案1】:

    但是如果你先 fork() 并在子进程中执行,子进程只有一个线程,并且会被 exec 函数破坏。父进程及其所有线程不受影响。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-01
      • 1970-01-01
      • 2011-09-09
      • 2012-11-13
      相关资源
      最近更新 更多