def start_process_monitor(self):
<EOL>Log.info("<STR_LIT>")<EOL>while True:<EOL><INDENT>if len(self.processes_to_monitor) > <NUM_LIT:0>:<EOL><INDENT>(pid, status) = os.wait()<EOL>with self.process_lock:<EOL><INDENT>if pid in list(self.processes_to_monitor.keys()):<EOL><INDENT>old_process_info = self.processes_to_monitor[pid]<EOL>name = old_process_info.name<EOL>command = old_process_info.command<EOL>Log.info("<STR_LIT>" % (name, pid, status, command))<EOL>self._wait_process_std_out_err(name, old_process_info.process)<EOL>if os.path.isfile("<STR_LIT>" % pid):<EOL><INDENT>os.system("<STR_LIT>" % pid)<EOL><DEDENT>if old_process_info.attempts >= self.max_runs:<EOL><INDENT>Log.info("<STR_LIT>" % name)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>time.sleep(self.interval_between_runs)<EOL>p = self._run_process(name, command)<EOL>del self.processes_to_monitor[pid]<EOL>self.processes_to_monitor[p.pid] =ProcessInfo(p, name, command, old_process_info.attempts + <NUM_LIT:1>)<EOL>log_pid_for_process(name, p.pid)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>
Monitor all processes in processes_to_monitor dict,
        restarting any if they fail, up to max_runs times.