You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Pointer to a buffer where the result code of the specified process will be stored, or **NULL**.
32
+
*`termstat`*\
33
+
Pointer to a buffer where the result code of the specified process will be stored, or **`NULL`**.
33
34
34
-
*procHandle*<br/>
35
+
*`procHandle`*\
35
36
The handle to the process to wait on (that is, the process that has to terminate before **_cwait** can return).
36
37
37
-
*action*<br/>
38
-
NULL: Ignored by Windows operating system applications; for other applications: action code to perform on *procHandle*.
38
+
*`action`*\
39
+
**`NULL`**: Ignored by Windows operating system applications; for other applications: action code to perform on *`procHandle`*.
39
40
40
41
## Return Value
41
42
42
-
When the specified process has successfully completed, returns the handle of the specified process and sets *termstat* to the result code that's returned by the specified process. Otherwise, returns -1 and sets **errno** as follows.
43
+
When the specified process has successfully completed, returns the handle of the specified process and sets *`termstat`* to the result code that's returned by the specified process. Otherwise, returns -1 and sets **`errno`** as follows.
43
44
44
45
|Value|Description|
45
46
|-----------|-----------------|
46
-
|**ECHILD**|No specified process exists, *procHandle* is invalid, or the call to the [GetExitCodeProcess](/windows/win32/api/processthreadsapi/nf-processthreadsapi-getexitcodeprocess) or [WaitForSingleObject](/windows/win32/api/synchapi/nf-synchapi-waitforsingleobject) API failed.|
47
-
|**EINVAL**|*action* is invalid.|
47
+
|**`ECHILD`**|No specified process exists, *`procHandle`* is invalid, or the call to the [`GetExitCodeProcess`](/windows/win32/api/processthreadsapi/nf-processthreadsapi-getexitcodeprocess) or [`WaitForSingleObject`](/windows/win32/api/synchapi/nf-synchapi-waitforsingleobject) API failed.|
48
+
|**`EINVAL`**|*`action`* is invalid.|
48
49
49
-
For more information about these and other return codes, see [errno, _doserrno, _sys_errlist, and _sys_nerr](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md).
50
+
For more information about these and other return codes, see [`errno, _doserrno, _sys_errlist, and _sys_nerr`](../../c-runtime-library/errno-doserrno-sys-errlist-and-sys-nerr.md).
50
51
51
52
## Remarks
52
53
53
-
The **_cwait** function waits for the termination of the process ID of the specified process that's provided by *procHandle*. The value of *procHandle* that's passed to **_cwait** should be the value that's returned by the call to the [_spawn](../../c-runtime-library/spawn-wspawn-functions.md) function that created the specified process. If the process ID terminates before **_cwait** is called, **_cwait** returns immediately. **_cwait** can be used by any process to wait for any other known process for which a valid handle (*procHandle*) exists.
54
+
The **`_cwait`** function waits for the termination of the process ID of the specified process that's provided by *`procHandle`*. The value of *`procHandle`* that's passed to **`_cwait`** should be the value that's returned by the call to the [`_spawn`](../../c-runtime-library/spawn-wspawn-functions.md) function that created the specified process. If the process ID terminates before **`_cwait`** is called, **`_cwait`** returns immediately. **`_cwait`** can be used by any process to wait for any other known process for which a valid handle (*`procHandle`*) exists.
54
55
55
-
*termstat* points to a buffer where the return code of the specified process will be stored. The value of *termstat* indicates whether the specified process terminated normally by calling the Windows [ExitProcess](/windows/win32/api/processthreadsapi/nf-processthreadsapi-exitprocess) API. **ExitProcess** is called internally if the specified process calls **exit** or **_exit**, returns from **main**, or reaches the end of **main**. For more information about the value that's passed back through *termstat*, see [GetExitCodeProcess](/windows/win32/api/processthreadsapi/nf-processthreadsapi-getexitcodeprocess). If **_cwait** is called by using a **NULL** value for *termstat*, the return code of the specified process is not stored.
56
+
*`termstat`* points to a buffer where the return code of the specified process will be stored. The value of *`termstat`* indicates whether the specified process terminated normally by calling the Windows [`ExitProcess`](/windows/win32/api/processthreadsapi/nf-processthreadsapi-exitprocess) API. **`ExitProcess`** is called internally if the specified process calls **`exit`** or **`_exit`**, returns from **`main`**, or reaches the end of **`main`**. For more information about the value that's passed back through *`termstat`*, see [GetExitCodeProcess](/windows/win32/api/processthreadsapi/nf-processthreadsapi-getexitcodeprocess). If **`_cwait`** is called by using a **`NULL`** value for *`termstat`*, the return code of the specified process isn't stored.
56
57
57
-
The *action* parameter is ignored by the Windows operating system because parent-child relationships are not implemented in these environments.
58
+
The *`action`* parameter is ignored by the Windows operating system because parent-child relationships aren't implemented in these environments.
58
59
59
-
Unless *procHandle* is -1 or -2 (handles to the current process or thread), the handle will be closed. Therefore, in this situation, do not use the returned handle.
60
+
Unless *`procHandle`* is -1 or -2 (handles to the current process or thread), the handle will be closed. In this situation, don't use the returned handle.
60
61
61
62
By default, this function's global state is scoped to the application. To change this, see [Global state in the CRT](../global-state.md).
0 commit comments