# <waitforexit>

[This is preliminary documentation and subject to change.]

Waits for a given process on the local computer to exit.

When used in combination with the <exec> task, it allows processed to be spawned for a certain duration or task, and then wait until the process is finished before continueing.

When the process identified by `pid` is no longer running, then the outcome is considered successful.

### Parameters

Attribute | Type | Description | Required
--- | --- | --- | ---
pid | int | The unique identifier of the process to wait for. | True
timeout | int | The maximum amount of time to wait until the process is exited, expressed in milliseconds. The default is to wait indefinitely. | False
failonerror | bool | Determines if task failure stops the build, or is just reported. The default is true. | False
if | bool | If true then the task will be executed; otherwise, skipped. The default is true. | False
unless | bool | Opposite of `if`. If false then the task will be executed; otherwise, skipped. The default is false. | False
verbose | bool | Determines whether the task should report detailed build log messages. The default is false. | False

### Examples

- Starts two batch processes, and waits for them to finish.

      <exec program="batch1.exe" pidproperty="batch1.pid" spawn="true" />
      <exec program="batch2.exe" pidproperty="batch2.pid" spawn="true" />
      <waitforexit pid="${batch1.pid}" />
      <waitforexit pid="${batch2.pid}" />

### Requirements

Assembly: NAnt.Contrib.Tasks (0.93.5002.0)