From: sof Date: Fri, 21 Nov 2003 16:24:44 +0000 (+0000) Subject: [project @ 2003-11-21 16:24:44 by sof] X-Git-Tag: nhc98-1-18-release~441 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=a9c26b2a05dfec2bf64e2d369caad53aed5fde93;hp=a5b806e511edac24c12213090ce32491652a1a1c;p=haskell-directory.git [project @ 2003-11-21 16:24:44 by sof] code tidyup --- diff --git a/cbits/rawSystem.c b/cbits/rawSystem.c index 20d6b4e..846ceee 100644 --- a/cbits/rawSystem.c +++ b/cbits/rawSystem.c @@ -57,24 +57,21 @@ rawSystem(HsAddr cmd) PROCESS_INFORMATION pInfo; DWORD retCode; - sInfo.cb = sizeof(STARTUPINFO); - sInfo.lpReserved = NULL; - sInfo.lpReserved2 = NULL; - sInfo.cbReserved2 = 0; - sInfo.lpDesktop = NULL; - sInfo.lpTitle = NULL; - sInfo.dwFlags = 0; - - if (!CreateProcess(NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &sInfo, &pInfo)) + ZeroMemory(&sInfo, sizeof(sInfo)); + sInfo.cb = sizeof(sInfo); + + if (!CreateProcess(NULL, cmd, NULL, NULL, TRUE, 0, NULL, NULL, &sInfo, &pInfo)) { /* The 'TRUE' says that the created process should share handles with the current process. This is vital to ensure that error messages sent to stderr actually appear on the screen. Since we are going to wait for the process to terminate anyway, there is no problem with such sharing. */ - return -1; + return -1; + } WaitForSingleObject(pInfo.hProcess, INFINITE); if (GetExitCodeProcess(pInfo.hProcess, &retCode) == 0) return -1; + CloseHandle(pInfo.hProcess); CloseHandle(pInfo.hThread); return retCode;