pyjfuzz/core/pjf_process_monitor.py
def start_monitor(self, standalone=True):
        """
        Run command in a loop and check exit status plus restart process when needed
        """
        try:
            self.start()
            cmdline = shlex.split(self.config.process_to_monitor)
            if standalone:
                signal.signal(signal.SIGINT, self.shutdown)
            self.process = subprocess.Popen(cmdline, stdin=PIPE, stdout=PIPE, stderr=PIPE)
            while self.process and not self.finished:
                self.process.wait()
                if self._is_sigsegv(self.process.returncode):
                    if self.config.debug:
                        print("[\033[92mINFO\033[0m] Process crashed with \033[91mSIGSEGV\033[0m, waiting for testcase...")
                    while not self.got_testcase():
                        time.sleep(1)
                    self.save_testcase(self.testcase[-10:])  # just take last 10 testcases
                if self.process:
                    self.process = subprocess.Popen(cmdline, stdin=PIPE, stdout=PIPE, stderr=PIPE)
        except OSError:
            self.shutdown()
            self.process = False
            self.got_testcase = lambda: True
            raise PJFProcessExecutionError("Binary <%s> does not exist" % cmdline[0])
        except Exception as e:
            raise PJFBaseException("Unknown error please send log to author")
def start_monitor(self, standalone=True):
        try:
            self.start()
            cmdline = shlex.split(self.config.process_to_monitor)
            if standalone:
                signal.signal(signal.SIGINT, self.shutdown)
            self.process = subprocess.Popen(cmdline, stdin=PIPE, stdout=PIPE, stderr=PIPE)
            while self.process and not self.finished:
                self.process.wait()
                if self._is_sigsegv(self.process.returncode):
                    if self.config.debug:
                        print("[\033[92mINFO\033[0m] Process crashed with \033[91mSIGSEGV\033[0m, waiting for testcase...")
                    while not self.got_testcase():
                        time.sleep(1)
                    self.save_testcase(self.testcase[-10:])  # just take last 10 testcases
                if self.process:
                    self.process = subprocess.Popen(cmdline, stdin=PIPE, stdout=PIPE, stderr=PIPE)
        except OSError:
            self.shutdown()
            self.process = False
            self.got_testcase = lambda: True
            raise PJFProcessExecutionError("Binary <%s> does not exist" % cmdline[0])
        except Exception as e:
            raise PJFBaseException("Unknown error please send log to author")
def start_monitor ( self , standalone = True ) : try : self . start ( ) cmdline = shlex . split ( self . config . process_to_monitor ) if standalone : signal . signal ( signal . SIGINT , self . shutdown ) self . process = subprocess . Popen ( cmdline , stdin = PIPE , stdout = PIPE , stderr = PIPE ) while self . process and not self . finished : self . process . wait ( ) if self . _is_sigsegv ( self . process . returncode ) : if self . config . debug : print ( "[\033[92mINFO\033[0m] Process crashed with \033[91mSIGSEGV\033[0m, waiting for testcase..." ) while not self . got_testcase ( ) : time . sleep ( 1 ) self . save_testcase ( self . testcase [ - 10 : ] ) # just take last 10 testcases if self . process : self . process = subprocess . Popen ( cmdline , stdin = PIPE , stdout = PIPE , stderr = PIPE ) except OSError : self . shutdown ( ) self . process = False self . got_testcase = lambda : True raise PJFProcessExecutionError ( "Binary <%s> does not exist" % cmdline [ 0 ] ) except Exception as e : raise PJFBaseException ( "Unknown error please send log to author" )
Run command in a loop and check exit status plus restart process when needed
Run command in a loop and check exit status plus restart process when needed