mirror of
https://github.com/reactos/reactos.git
synced 2024-09-01 16:18:46 +00:00
42 lines
773 B
C
42 lines
773 B
C
/*
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
* PROJECT: ReactOS system libraries
|
|
* FILE: lib/sdk/crt/process/_cwait.c
|
|
* PURPOSE: Waits for a process to exit
|
|
*/
|
|
|
|
#include <precomp.h>
|
|
|
|
/* Taken from Wine msvcrt/process.c */
|
|
|
|
/*
|
|
* @implemented
|
|
*/
|
|
intptr_t CDECL _cwait(int *status, intptr_t pid, int action)
|
|
{
|
|
HANDLE hPid = (HANDLE)pid;
|
|
int doserrno;
|
|
|
|
if (!WaitForSingleObject(hPid, INFINITE))
|
|
{
|
|
if (status)
|
|
{
|
|
DWORD stat;
|
|
GetExitCodeProcess(hPid, &stat);
|
|
*status = (int)stat;
|
|
}
|
|
return pid;
|
|
}
|
|
doserrno = GetLastError();
|
|
|
|
if (doserrno == ERROR_INVALID_HANDLE)
|
|
{
|
|
*_errno() = ECHILD;
|
|
*__doserrno() = doserrno;
|
|
}
|
|
else
|
|
_dosmaperr(doserrno);
|
|
|
|
return status ? *status = -1 : -1;
|
|
}
|