ReactOS 0.4.15-dev-8235-gcd88a97
_cwait.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * FILE: lib/sdk/crt/process/_cwait.c
5 * PURPOSE: Waits for a process to exit
6 */
7
8#include <precomp.h>
9
10/* Taken from Wine msvcrt/process.c */
11
12/*
13 * @implemented
14 */
16{
17 HANDLE hPid = (HANDLE)pid;
18 int doserrno;
19
20 if (!WaitForSingleObject(hPid, INFINITE))
21 {
22 if (status)
23 {
24 DWORD 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}
intptr_t CDECL _cwait(int *status, intptr_t pid, int action)
Definition: _cwait.c:15
#define stat
Definition: acwin.h:99
int intptr_t
Definition: crtdefs.h:304
#define CDECL
Definition: compat.h:29
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
BOOL WINAPI GetExitCodeProcess(IN HANDLE hProcess, IN LPDWORD lpExitCode)
Definition: proc.c:1168
const WCHAR * action
Definition: action.c:7479
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define ECHILD
Definition: errno.h:16
#define INFINITE
Definition: serial.h:102
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP unsigned long *__cdecl __doserrno(void)
Definition: errno.c:25
void _dosmaperr(unsigned long oserrcode)
Definition: errno.c:79
_CRTIMP int *__cdecl _errno(void)
Definition: errno.c:17
Definition: stat.h:55
Definition: ps.c:97
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
PVOID HANDLE
Definition: typedefs.h:73
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ ULONG_PTR _In_ ULONG _Out_ ULONG_PTR * pid
Definition: winddi.h:3837