X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fcore%2Fwindows%2Fprocess.cpp;h=3bd03fa3816dbefc3faa71726fa1632c5537cdcd;hb=HEAD;hp=829365088115289bcdedc0ebc315911f3bf3175c;hpb=5126e0aab38f902d6c54c517c9986ff0d0539afd;p=libs%2Fcore.git diff --git a/source/core/windows/process.cpp b/source/core/windows/process.cpp index 8293650..0eae33b 100644 --- a/source/core/windows/process.cpp +++ b/source/core/windows/process.cpp @@ -1,7 +1,8 @@ -#include +#include "winapi.h" #include #include #include +#include "except.h" #include "process.h" #include "process_private.h" @@ -43,12 +44,13 @@ Process::~Process() { CloseHandle(priv->info.hProcess); CloseHandle(priv->info.hThread); + delete priv; } void Process::platform_get_self_info(Private &priv) { priv.info.hProcess = GetCurrentProcess(); - priv.info.hThread = 0; + priv.info.hThread = nullptr; priv.info.dwProcessId = GetCurrentProcessId(); priv.info.dwThreadId = 0; } @@ -61,12 +63,12 @@ void Process::execute(const string &command, bool path_search, const Arguments & STARTUPINFO startup; startup.cb = sizeof(STARTUPINFO); - startup.lpReserved = 0; - startup.lpDesktop = 0; - startup.lpTitle = 0; + startup.lpReserved = nullptr; + startup.lpDesktop = nullptr; + startup.lpTitle = nullptr; startup.dwFlags = 0; startup.cbReserved2 = 0; - startup.lpReserved2 = 0; + startup.lpReserved2 = nullptr; if(redirect) { startup.dwFlags |= STARTF_USESTDHANDLES; @@ -78,9 +80,9 @@ void Process::execute(const string &command, bool path_search, const Arguments & HANDLE cerr_handle = (cerr ? *cerr->get_handle(IO::M_WRITE) : GetStdHandle(STD_ERROR_HANDLE)); DuplicateHandle(self_handle, cerr_handle, self_handle, &startup.hStdError, 0, true, DUPLICATE_SAME_ACCESS); } - const char *cmdptr = (path_search ? 0 : command.c_str()); - const char *wd = (work_dir.empty() ? 0 : work_dir.c_str()); - if(!CreateProcess(cmdptr, const_cast(cmdline.c_str()), 0, 0, true, 0, 0, wd, &startup, &priv->info)) + const char *cmdptr = (path_search ? nullptr : command.c_str()); + const char *wd = (work_dir.empty() ? nullptr : work_dir.c_str()); + if(!CreateProcess(cmdptr, const_cast(cmdline.c_str()), nullptr, nullptr, true, 0, nullptr, wd, &startup, &priv->info)) throw system_error("CreateProcess"); if(redirect) @@ -99,7 +101,7 @@ void Process::execute(const string &command, bool path_search, const Arguments & bool Process::wait(bool block) { if(!running) - throw logic_error("not running"); + throw invalid_state("not running"); DWORD ret = WaitForSingleObject(priv->info.hProcess, (block ? INFINITE : 0)); if(ret==WAIT_FAILED) @@ -135,8 +137,8 @@ void Process::interrupt() Process::Private::Private() { - info.hProcess = 0; - info.hThread = 0; + info.hProcess = nullptr; + info.hThread = nullptr; info.dwProcessId = 0; info.dwThreadId = 0; }