:pserver:cvsanon@mok.lvcm.com:/CVS/ReactOS reactos
[reactos.git] / lib / crtdll / process / _cwait.c
1 /*
2  * COPYRIGHT:   See COPYING in the top level directory
3  * PROJECT:     ReactOS system libraries
4  * FILE:        lib/crtdll/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 #include <windows.h>
11 #include <crtdll/process.h>
12 #include <crtdll/errno.h>
13 #include <crtdll/internal/file.h>
14
15 int _cwait (int* pnStatus, int hProc, int nAction)
16 {
17   DWORD ExitCode;
18
19         nAction = 0;
20         if ( WaitForSingleObject((void *)hProc,INFINITE) != WAIT_OBJECT_0 ) {
21                 __set_errno(ECHILD);
22                 return -1;
23         }
24
25         if ( !GetExitCodeProcess((void *)hProc,&ExitCode) )
26                 return -1;
27         if (pnStatus != NULL)
28           *pnStatus = (int)ExitCode;
29         return hProc;
30 }