ReactOS  0.4.15-dev-1070-ge1a01de
_cwait.c File Reference
#include <precomp.h>
Include dependency graph for _cwait.c:

Go to the source code of this file.

Functions

intptr_t CDECL _cwait (int *status, intptr_t pid, int action)
 

Function Documentation

◆ _cwait()

intptr_t CDECL _cwait ( int status,
intptr_t  pid,
int  action 
)

Definition at line 15 of file _cwait.c.

16 {
17  HANDLE hPid = (HANDLE)pid;
18  int doserrno;
19 
20  if (!WaitForSingleObject(hPid, INFINITE))
21  {
22  if (status)
23  {
24  DWORD stat;
25  GetExitCodeProcess(hPid, &stat);
26  *status = (int)stat;
27  }
28  return pid;
29  }
30  doserrno = GetLastError();
31 
32  if (doserrno == ERROR_INVALID_HANDLE)
33  {
34  *_errno() = ECHILD;
35  *__doserrno() = doserrno;
36  }
37  else
38  _dosmaperr(doserrno);
39 
40  return status ? *status = -1 : -1;
41 }
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3835
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
Definition: proc.c:1168
_CRTIMP unsigned long *__cdecl __doserrno(void)
Definition: errno.c:27
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
unsigned long DWORD
Definition: ntddk_ex.h:95
PVOID HANDLE
Definition: typedefs.h:73
_CRTIMP int *__cdecl _errno(void)
Definition: errno.c:19
Definition: stat.h:55
void _dosmaperr(unsigned long oserrcode)
Definition: errno.c:81
#define ECHILD
Definition: errno.h:16
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
#define INFINITE
Definition: serial.h:102
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
Definition: ps.c:97