0

我正在用 C 语言编写一个简单的应用程序,需要作为守护进程运行。

我通过分叉并关闭stderr、stdout、stdin来妖魔化这个过程。我的问题是?分叉的进程是从父进程继承动态加载的库还是我需要再次加载它们?

如果它继承它们,模块将被加载到与父进程中相同的虚拟地址?

4

1 回答 1

1

Yes, after a fork the new child process will have a copy-on-write clone of the parent's memory space, which includes any shared libraries which may have been loaded and initialized. At the function call level, anything you could have done in the parent you can do legally in the child.

于 2013-05-28T18:49:51.807 回答