{
do
{
if (cmd.empty())
{
reason = PARAMS_ERROR ":empty cmd";
break;
}
FILE *pipe = popen(cmd.c_str(),"r");
if (!pipe)
{
reason = SERVER_ERROR ":popen failed:" + Common::String(strerror(errno));
break;
}
char buff[1024] = {0};
while(!feof(pipe))
{
if(fgets(buff,1024,pipe))
result += buff;
}
pclose(pipe);
return true;
} while (0);
return false;
}
请问各位,上面代码调用频率大概一分钟有10次,偶尔会产生coredump,一直找不到原因,上生产用的就出问题,虽然不影响业务,但是一堆core文件看着很头疼。系统是centos7
以下是coredump文件的堆栈信息。
#0 0x00007fd8ca0e05ae in _IO_proc_open@@GLIBC_2.2.5 () from /lib64/libc.so.6
#1 0x00007fd8ca0e066c in popen@@GLIBC_2.2.5 () from /lib64/libc.so.6
#2 0x000000000042d508 in xxxx::xxxx (this=<optimized out>, cmd=..., result=..., reason=...) at xxxx.cpp:1011
#3 0x0000000000517b2a in Common::ServerCallI::execute (this=0x4a0db80) at ../../.././src/Common/CommonI.cpp:1381
#4 0x0000000000513755 in Common::EventManagerI::processExecute (this=<optimized out>, processor=..., execute=0x4a0dba0) at ../../
#5 0x0000000000518c38 in Common::EventManagerI::process (this=0x29ae000, processor=...) at ../../.././src/Common/CommonI.cpp:1851
#6 0x0000000000519693 in Common::Processor::onRun (this=0x29ab590) at ../../.././src/Common/CommonI.cpp:1301
#7 0x00000000005ea408 in Common::Thread::entry (params=0x29ab590) at ../../.././src/Common/UtilI.cpp:1548
#8 0x00007fd8cae6dea5 in start_thread () from /lib64/libpthread.so.0
#9 0x00007fd8ca16e9fd in clone () from /lib64/libc.so.6
会是哪些原因导致的,帮我指明一下调查方向或者有哪些解决方案