mirror of
https://github.com/reactos/reactos.git
synced 2024-10-30 03:27:31 +00:00
7dd4d2256b
This is a rather graceful approach compared to sysreg2's 3 minute timeout before killing and restarting the entire VM. Since we added autochk for FAT filesystems, the filesystem is often "fixed" after a reset with the consequence that ReactOS doesn't boot up anymore. The sysreg2 restart code still remains for handling tests causing BSODs.
38 lines
1.2 KiB
C++
38 lines
1.2 KiB
C++
/*
|
|
* PROJECT: ReactOS Automatic Testing Utility
|
|
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
|
|
* PURPOSE: Class able to create a new process and closing its handles on destruction (exception-safe)
|
|
* COPYRIGHT: Copyright 2009-2019 Colin Finck (colin@reactos.org)
|
|
*/
|
|
|
|
#include "precomp.h"
|
|
|
|
/**
|
|
* Constructs a CProcess object and uses the CreateProcessW function to start the process immediately.
|
|
*
|
|
* @param CommandLine
|
|
* A std::wstring containing the command line to run
|
|
*
|
|
* @param StartupInfo
|
|
* Pointer to a STARTUPINFOW structure containing process startup information
|
|
*/
|
|
CProcess::CProcess(const wstring& CommandLine, LPSTARTUPINFOW StartupInfo)
|
|
{
|
|
auto_array_ptr<WCHAR> CommandLinePtr(new WCHAR[CommandLine.size() + 1]);
|
|
|
|
wcscpy(CommandLinePtr, CommandLine.c_str());
|
|
|
|
if(!CreateProcessW(NULL, CommandLinePtr, NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, StartupInfo, &m_ProcessInfo))
|
|
TESTEXCEPTION("CreateProcessW failed\n");
|
|
}
|
|
|
|
/**
|
|
* Destructs a CProcess object, terminates the process if running, and closes all handles belonging to the process.
|
|
*/
|
|
CProcess::~CProcess()
|
|
{
|
|
TerminateProcess(m_ProcessInfo.hProcess, 255);
|
|
CloseHandle(m_ProcessInfo.hThread);
|
|
CloseHandle(m_ProcessInfo.hProcess);
|
|
}
|