求问一个ShellExecuteEx进程句柄泄漏的问题
我有一个windows下的服务进程程序,系统是win2008server。
服务做的主要事情就是不断用ShellExecuteEx调用另一个EXE进程。
最近发现有时服务进程内存高达几百M,句柄数达到几百万。
用process ex一看,服务进程里有大量的file句柄,但这些文件服务进程是不用的,而是另一个EXE进程所用。
EXE进程都已经退出,即使它有泄漏,怎么会跑到服务进程里去呢?
子进程启动和监视代码简化如下
memset(&ShExecInfo, 0x00, sizeof(ShExecInfo));
ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
ShExecInfo.fMask = SEE_MASK_NOCLOSEPROCESS | SEE_MASK_FLAG_NO_UI;
ShExecInfo.hwnd = NULL;
ShExecInfo.lpVerb = NULL;
ShExecInfo.lpFile = szRealExe;
ShExecInfo.lpParameters = sCommandLine;
ShExecInfo.lpDirectory = NULL;
ShExecInfo.nShow = SW_SHOW;
ShExecInfo.hInstApp = NULL;
if ( ShellExecuteEx(&ShExecInfo)==FALSE )
nWait = WaitForSingleObject(ShExecInfo.hProcess, );
if ( nWait==WAIT_OBJECT_0 )
{
}
if ( nWait==WAIT_TIMEOUT )
{
TerminateProcess(ShExecInfo.hProcess, 999);
}
if ( ShExecInfo.hProcess )
{
CloseHandle(ShExecInfo.hProcess);
ShExecInfo.hProcess = NULL;
}
谢谢!