- Cleanup the /lib directory, by putting more 3rd-party libs in /3rdparty, and by...
[reactos.git] / reactos / lib / sdk / 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: Ariadne
7 * UPDATE HISTORY:
8 * 04/03/99: Created
9 */
10
11 #include <precomp.h>
12
13 /*
14 * @implemented
15 */
16 int _cwait(int* pnStatus, int hProc, int nAction)
17 {
18 DWORD ExitCode;
19
20 nAction = 0;
21 if (WaitForSingleObject((void*)ULongToPtr(hProc), INFINITE) != WAIT_OBJECT_0) {
22 __set_errno(ECHILD);
23 return -1;
24 }
25
26 if (!GetExitCodeProcess((void*)ULongToPtr(hProc), &ExitCode))
27 return -1;
28 if (pnStatus != NULL)
29 *pnStatus = (int)ExitCode;
30 CloseHandle((HANDLE)ULongToPtr(hProc));
31 return hProc;
32 }