* PROJECT: ReactOS system libraries
* FILE: lib/msvcrt/process/cwait.c
* PURPOSE: Waits for a process to exit
- * PROGRAMER: Ariadne
- * UPDATE HISTORY:
- * 04/03/99: Created
*/
#include <precomp.h>
+/* Taken from Wine msvcrt/process.c */
+
/*
* @implemented
*/
-int _cwait(int* pnStatus, int hProc, int nAction)
+intptr_t CDECL _cwait(int *status, intptr_t pid, int action)
{
- DWORD ExitCode;
+ HANDLE hPid = (HANDLE)pid;
+ int doserrno;
+
+ if (!WaitForSingleObject(hPid, INFINITE))
+ {
+ if (status)
+ {
+ DWORD stat;
+ GetExitCodeProcess(hPid, &stat);
+ *status = (int)stat;
+ }
+ return pid;
+ }
+ doserrno = GetLastError();
- nAction = 0;
- if (WaitForSingleObject((void*)ULongToPtr(hProc), INFINITE) != WAIT_OBJECT_0) {
- _set_errno(ECHILD);
- return -1;
- }
+ if (doserrno == ERROR_INVALID_HANDLE)
+ {
+ *_errno() = ECHILD;
+ *__doserrno() = doserrno;
+ }
+ else
+ _dosmaperr(doserrno);
- if (!GetExitCodeProcess((void*)ULongToPtr(hProc), &ExitCode))
- return -1;
- if (pnStatus != NULL)
- *pnStatus = (int)ExitCode;
- CloseHandle((HANDLE)ULongToPtr(hProc));
- return hProc;
+ return status ? *status = -1 : -1;
}
msvcrt -
reactos/lib/sdk/crt/except/cpp.c # Synced at 20080528
reactos/lib/sdk/crt/except/cppexcept.c # Synced at 20071111
+ reactos/lib/sdk/crt/process/_cwait.c # Synced to WineStaging-1.7.37
reactos/lib/sdk/crt/signal/xcptinfo.c # Synced to Wine-1.7.17
reactos/lib/sdk/crt/string/scanf.c/h # Synced to Wine-1.7.17
reactos/lib/sdk/crt/strings/wcs.c # Synced at 20080611