C++ linux下启动新进程并终止当前进程
这个问题已在这里被问过几次,但我找不到以下情况的答案:
我的程序使用静态链接库,它打开文件句柄,因此,我无法在这些文件句柄上设置 FD_CLOEXEC ,
只需调用 exec 原因由于文件句柄不可用,新进程中出现很多错误
基本上我需要:
1. 生成新进程而不阻塞当前进程
2.终止当前进程(关闭所有句柄)
我可以在linux上这样做吗?
This question has been asked several times here, but I can't find answer for the following situation:
My program uses statically linked libraries, which open file handles, so, I'm unable to set FD_CLOEXEC on those file handles
simply calling exec causes alot of errors in new process, because of unavailable file handles
Basically I need:
1. spawn new process without blocking current one
2. terminate current process (close all handles)
Can I do it on linux?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关闭所有文件描述符应该像这样简单,
这也是守护进程期间的标准步骤,请参见 http: //www.enderunix.org/docs/eng/daemon.php
Closing all filedescriptors should be as simple as
This is also a standard step during daemonizing, see e.g. http://www.enderunix.org/docs/eng/daemon.php