# %wait() function

The %wait() function returns the exit
code of the child processes created by the current process.

**For Windows:** Not Supported

## Syntax

```
var = %wait(&status)
```

## Description

The status is returned in the
integer *status*, passed by its address.

Note
that even though *status* is an integer, only the
lower 16 bits are updated by the system call. See the UNIX system
documentation for more details on the format of the returned status.

Note: Before passing the address of *status*, the
variable must have been initialized to an integer value.

## Example(s)

```
status=0
(void)%wait(&status)
high$status=int(status/256)
low$status=mod(status,256)
begin case
case low$status=255
* Child stopped due to a signal
case low$status=0
* Child stopped by calling exit()
case high$status=0
* Child was terminated due to a signal
end case
```

## See also

- [FlashBASIC C functions overview](https://d3codex.com/pickbasic-flashbasic/flashbasic-c-functions-overview/)
- [cfunction statement](https://d3codex.com/pickbasic-flashbasic/cfunction-statement/)

---
Source: https://d3codex.com/pickbasic-flashbasic/percent-wait-function/ - part of the D3Codex reference.
