예제 #1
0
파일: winp.cpp 프로젝트: activeeon/winp
//---------------------------------------------------------------------------
// KillProcessTreeWinHelper
//
//  This is a recursive helper function that terminates all the processes
//  started by the specified process and them terminates the process itself
//
//  Parameters:
//	  dwProcessId - identifier of the process to terminate
//
//  Returns:
//	  Win32 error code.
//
BOOL WINAPI KillProcessTreeWinHelper(DWORD dwProcessId) {
	// create a snapshot
	auto_handle hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
	if (!hSnapshot)
		return GetLastError();

	auto_localmem<PROCESSENTRY32*> pEntry(sizeof(PROCESSENTRY32));

	pEntry->dwSize = sizeof(PROCESSENTRY32);
	if (!Process32First(hSnapshot, pEntry))
	{
		return GetLastError();
	}

	// kill all children first
	do
	{
		// there was a report of infinite recursion, so watching out for the obvious self-loop possibility
		DWORD pid = pEntry->th32ProcessID;
		if (pEntry->th32ParentProcessID == dwProcessId && dwProcessId!=pid)
			KillProcessTreeWinHelper(pid);
	}
	while (Process32Next(hSnapshot, pEntry));

	// kill the process itself
    if (!KillProcess(dwProcessId))
		return GetLastError();

	return ERROR_SUCCESS;
}
예제 #2
0
CDirEntry *CDirList::AddEntry(const wxString &sInputDir, const wxString &sOutputDir)
{
  CDirEntry *pEntry(new CDirEntry(sInputDir,sOutputDir,m_sTimeStamp));
  pEntry->SetParmOsiris(m_parmOsiris);
  pEntry->SetIndex((long)m_vpDir->size());
  m_vpDir->push_back(pEntry);
  return pEntry;
}
예제 #3
0
	void TypeInference::inferTypes(
			const list<ClassDefBasePtr>& classes,
			const StaticContextPtr& pRootCtx,
			const LogPtr& pLog)
	{
		list<ClassDefBasePtr>::const_iterator cit;

		for (cit = classes.begin(); cit != classes.end(); cit++)
		{
			const ClassDefBasePtr& pClassDefBase = *cit;

			if (pClassDefBase->getASTNodeType() == ASTN_INTERFACE)
			{
				continue;
			}

			StaticContextPtr pClassCtx;
			StaticContextHelper::newClassContext(pClassCtx, pClassDefBase, pRootCtx, pLog);

			StaticContextPtr pInstanceCtx;
			StaticContextHelper::newInstanceContext(pInstanceCtx, pClassDefBase, pRootCtx, pLog);

			const list<VariableDeclDefPtr>& variables = pClassDefBase->getVariableDecls();

			list<VariableDeclDefPtr>::const_iterator vit;

			for (vit = variables.begin(); vit != variables.end(); vit++)
			{
				const VariableDeclDefPtr& pVariable = *vit;
				const ValueDefPtr& pValueDef = pVariable->getValue();

				if (pValueDef.get() == NULL)
				{
					// this is reported by ClassCheck
					continue;
				}

				StaticContextPtr& pParentCtx = (pVariable->isStatic() ? pClassCtx : pInstanceCtx);

				StaticContextPtr pMemberCtx(new StaticContext(pParentCtx, pVariable->isStatic()));
				
				inferTypes(*pValueDef, pMemberCtx, pLog);

				StaticContextEntryPtr pEntry(new StaticContextEntry(pVariable));
				pParentCtx->addEntry(pEntry);
			}
		}
	}