* @brief Encapsulate a process handle, should be inherited by other class */
| 16 | * @brief Encapsulate a process handle, should be inherited by other class |
| 17 | */ |
| 18 | class ProcessBase |
| 19 | { |
| 20 | public: |
| 21 | |
| 22 | /** |
| 23 | * @brief Wait for the process handle to exit |
| 24 | * @return the exit code of the process |
| 25 | */ |
| 26 | [[maybe_unused]] int WaitForExit() const |
| 27 | { |
| 28 | WaitForSingleObject(m_processHandle, INFINITE); |
| 29 | DWORD exitCode{}; |
| 30 | GetExitCodeProcess(m_processHandle, &exitCode); |
| 31 | CloseHandle(m_processHandle); |
| 32 | return exitCode; |
| 33 | } |
| 34 | |
| 35 | [[nodiscard]] HANDLE Handle() const { return m_processHandle; } |
| 36 | |
| 37 | void Terminate() |
| 38 | { |
| 39 | TerminateProcess(m_processHandle, 1); |
| 40 | } |
| 41 | protected: |
| 42 | HANDLE m_processHandle; |
| 43 | }; |
| 44 | } |
| 45 | |
| 46 | template<typename Char> |
nothing calls this directly
no outgoing calls
no test coverage detected