c++ - gperftools + apache + fcgi ,它不会写入文件

标签 c++ apache fastcgi gperftools

我正在尝试使用 mod_fascgiperftools 分析在 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/

相关文章:

c++ - 传递给非主函数的数组上基于范围的for循环

windows - 如何让配置文件自动为所有页面添加 'global' 模块

apache - fsimage hdfs 的内容

apache - 将 ColdFusion 11 连接到远程 Solr

php - 用 Nginx 和 PHP 重写 fastcgi 仍然发送旧的 request_uri 到后端(php 和 symfony)

c++ - 对 FCGI 概念感到困惑

php - 服务器崩溃可能会泄露php源代码?

c++ - 从 C++ 中的 .obj 文件中读取整数

C++多维数据可视化

c++ - 如何分隔 C++ 字符串中的数字和字母?