我正在尝试使用 mod_fascgi
和 perftools
分析在 apache
中运行的 fcgi
应用程序 (C++) >。所以是 Centos 6 x86_64。
问题如下。根据gperftools documentation
"For security reasons, CPU profiling will not write to a file -- and is thus not usable -- for setuid programs."
Apache 必须作为 root
启动,然后使用 setuid 作为用户使用 apache
,因此使用 setuid
。然后 gperftools
不会写入文件。
并且以 root
身份运行 Apache 也被禁用。
有什么解决办法吗?
到目前为止,我想到了 3 种解决方案:
- 在应用程序中创建一个测试来模拟一些请求和模拟 FCGI 类。
- 使用标志 -DBIG_SECURITY_HOLE 重新编译 Apache,以允许以 root 身份运行 apache。
- 重新编译 gperftools 删除 suid 的检查。
最佳答案
我重新编译了 gperftools
并去掉了 suid 的检查。
唯一要记住的是,对于要写入的日志,您不能终止进程。并执行“service httpd stop”将终止进程(因此它不会刷新日志)。
您必须发送一个信号(阅读 gperftools 文档)或在您的主程序中添加 ProfileStart()
和 ProfileStop()
调用。
关于c++ - gperftools + apache + fcgi ,它不会写入文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24329217/