'Internal run loop of ProcessMonitor'

def _run(self):

    plock = self.plock
    dead = []
    respawn = []
    while (not self.is_shutdown):
        with plock:
            procs = self.procs[:]
        if self.is_shutdown:
            break
        for p in procs:
            try:
                if (not p.is_alive()):
                    exit_code_str = p.get_exit_description()
                    if p.respawn:
                        printlog_bold(('[%s]    %s\nrespawning...' % (p.name, exit_code_str)))
                        respawn.append(p)
                    elif p.required:
                        printerrlog(((('=' * 80) + ('REQUIRED    process    [%s]    has    died!\n%s\nInitiating    shutdown!\n' % (p.name, exit_code_str))) + ('=' * 80)))
                        self.is_shutdown = True
                    else:
                        if p.exit_code:
                            printerrlog(('[%s]    %s' % (p.name, exit_code_str)))
                        else:
                            printlog_bold(('[%s]    %s' % (p.name, exit_code_str)))
                        dead.append(p)
                    for l in self.listeners:
                        l.process_died(p.name, p.exit_code)
            except Exception as e:
                traceback.print_exc()
                dead.append(p)
            if self.is_shutdown:
                break
        for d in dead:
            try:
                self.unregister(d)
                d.stop([])
                with plock:
                    self.dead_list.append(DeadProcess(d))
            except Exception as e:
                printerrlog(('Exception:    %s' % str(e)))
        if (self._registrations_complete and dead and (not self.procs) and (not respawn)):
            printlog('all    processes    on    machine    have    died,    roslaunch    will    exit')
            self.is_shutdown = True
        del dead[:]
        for r in respawn:
            try:
                if self.is_shutdown:
                    break
                printlog(('[%s]    restarting    process' % r.name))
                r.stop([])
                r.start()
            except:
                traceback.print_exc()
        del respawn[:]
        time.sleep(0.1)
