2007-03-14 20:24:57 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
2015-09-19 13:50:57 +00:00
|
|
|
* FILE: lib/sdk/crt/process/_cwait.c
|
2007-03-14 20:24:57 +00:00
|
|
|
* PURPOSE: Waits for a process to exit
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <precomp.h>
|
|
|
|
|
2015-04-10 10:49:56 +00:00
|
|
|
/* Taken from Wine msvcrt/process.c */
|
|
|
|
|
2007-03-14 20:24:57 +00:00
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
2015-04-10 10:49:56 +00:00
|
|
|
intptr_t CDECL _cwait(int *status, intptr_t pid, int action)
|
2007-03-14 20:24:57 +00:00
|
|
|
{
|
2015-04-10 10:49:56 +00:00
|
|
|
HANDLE hPid = (HANDLE)pid;
|
|
|
|
int doserrno;
|
|
|
|
|
|
|
|
if (!WaitForSingleObject(hPid, INFINITE))
|
|
|
|
{
|
|
|
|
if (status)
|
|
|
|
{
|
|
|
|
DWORD stat;
|
|
|
|
GetExitCodeProcess(hPid, &stat);
|
|
|
|
*status = (int)stat;
|
|
|
|
}
|
|
|
|
return pid;
|
|
|
|
}
|
|
|
|
doserrno = GetLastError();
|
2007-03-14 20:24:57 +00:00
|
|
|
|
2015-04-10 10:49:56 +00:00
|
|
|
if (doserrno == ERROR_INVALID_HANDLE)
|
|
|
|
{
|
|
|
|
*_errno() = ECHILD;
|
|
|
|
*__doserrno() = doserrno;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_dosmaperr(doserrno);
|
2007-03-14 20:24:57 +00:00
|
|
|
|
2015-04-10 10:49:56 +00:00
|
|
|
return status ? *status = -1 : -1;
|
2007-03-14 20:24:57 +00:00
|
|
|
}
|