'Waits for the process to complete or to reach the given timeout.
The process to wait for must have been started earlier with
`Start Process`. If ``handle`` is not given, uses the current
`active process`.
``timeout`` defines the maximum time to wait for the process. It can be
given in
[http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#time-format|
various time formats] supported by Robot Framework, for example, ``42``,
``42 s``, or ``1 minute 30 seconds``.
``on_timeout`` defines what to do if the timeout occurs. Possible values
and corresponding actions are explained in the table below. Notice
that reaching the timeout never fails the test.
| = Value = |               = Action =               |
| continue  | The process is left running (default). |
| terminate | The process is gracefully terminated.  |
| kill      | The process is forcefully stopped.     |
See `Terminate Process` keyword for more details how processes are
terminated and killed.
If the process ends before the timeout or it is terminated or killed,
this keyword returns a `result object` containing information about
the execution. If the process is left running, Python ``None`` is
returned instead.
Examples:
| # Process ends cleanly      |                  |                  |
| ${result} =                 | Wait For Process | example          |
| Process Should Be Stopped   | example          |                  |
| Should Be Equal As Integers | ${result.rc}     | 0                |
| # Process does not end      |                  |                  |
| ${result} =                 | Wait For Process | timeout=42 secs  |
| Process Should Be Running   |                  |                  |
| Should Be Equal             | ${result}        | ${NONE}          |
| # Kill non-ending process   |                  |                  |
| ${result} =                 | Wait For Process | timeout=1min 30s | on_timeout=kill |
| Process Should Be Stopped   |                  |                  |
| Should Be Equal As Integers | ${result.rc}     | -9               |
``timeout`` and ``on_timeout`` are new in Robot Framework 2.8.2.'

def wait_for_process(self, handle=None, timeout=None, on_timeout='continue'):

    process = self._processes[handle]
    logger.info('Waiting    for    process    to    complete.')
    if timeout:
        timeout = timestr_to_secs(timeout)
        if (not self._process_is_stopped(process, timeout)):
            logger.info(('Process    did    not    complete    in    %s.' % secs_to_timestr(timeout)))
            return self._manage_process_timeout(handle, on_timeout.lower())
    return self._wait(process)
