fix some MSVC compile problems
[reactos.git] / reactos / lib / crt / process / _cwait.c
1 /*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/msvcrt/process/cwait.c
5 * PURPOSE: Waits for a process to exit
6 * PROGRAMER: Boudewijn Dekker
7 * UPDATE HISTORY:
8 * 04/03/99: Created
9 */
10
11 #include "precomp.h"
12 #include <process.h>
13 #include <errno.h>
14 #include <internal/file.h>
15
16
17 /*
18 * @implemented
19 */
20 int _cwait(int* pnStatus, int hProc, int nAction)
21 {
22 DWORD ExitCode;
23
24 nAction = 0;
25 if (WaitForSingleObject((void*)ULongToPtr(hProc), INFINITE) != WAIT_OBJECT_0) {
26 __set_errno(ECHILD);
27 return -1;
28 }
29
30 if (!GetExitCodeProcess((void*)ULongToPtr(hProc), &ExitCode))
31 return -1;
32 if (pnStatus != NULL)
33 *pnStatus = (int)ExitCode;
34 CloseHandle((HANDLE)ULongToPtr(hProc));
35 return hProc;
36 }