def monitor_running_process(context: RunContext):
while True:<EOL><INDENT>capture_output_from_running_process(context)<EOL>if context.process_finished():<EOL><INDENT>context.return_code = context.command.returncode<EOL>break<EOL><DEDENT>if context.process_timed_out():<EOL><INDENT>context.return_code = -<NUM_LIT:1><EOL>raise ProcessTimeoutError(<EOL>exe_name=context.exe_short_name,<EOL>timeout=context.timeout,<EOL>)<EOL><DEDENT><DEDENT>
Runs an infinite loop that waits for the process to either exit on its or time out

Captures all output from the running process

:param context: run context
:type context: RunContext