| 
						
						
							
								
							
						
						
					 | 
					@ -8,6 +8,7 @@ import ctypes | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import signal | 
					 | 
					 | 
					import signal | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					from Basis.Logger import logging | 
					 | 
					 | 
					from Basis.Logger import logging | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					from Basis.Functions import genFlag | 
					 | 
					 | 
					from Basis.Functions import genFlag | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					from Basis.Exception import processException | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					from subprocess import Popen, STDOUT, DEVNULL | 
					 | 
					 | 
					from subprocess import Popen, STDOUT, DEVNULL | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					libcPaths = [ | 
					 | 
					 | 
					libcPaths = [ | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -73,7 +74,7 @@ class Process(object): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                logging.error('[%s] %s already exist but not folder' % (self.id, self.workDir)) | 
					 | 
					 | 
					                logging.error('[%s] %s already exist but not folder' % (self.id, self.workDir)) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            else: | 
					 | 
					 | 
					            else: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                logging.error('[%s] Unable to create new folder -> %s' % (self.id, self.workDir)) | 
					 | 
					 | 
					                logging.error('[%s] Unable to create new folder -> %s' % (self.id, self.workDir)) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            raise RuntimeError('Working directory error')  # fatal error | 
					 | 
					 | 
					            raise processException('Working directory error')  # fatal error | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    def __killProcess(self, killSignal: int) -> None: | 
					 | 
					 | 
					    def __killProcess(self, killSignal: int) -> None: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        try: | 
					 | 
					 | 
					        try: | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -134,10 +135,10 @@ class Process(object): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        )) | 
					 | 
					 | 
					        )) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if self.cmd is None:  # ERROR CASE | 
					 | 
					 | 
					        if self.cmd is None:  # ERROR CASE | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            logging.error('[%s] Process miss start command' % self.id) | 
					 | 
					 | 
					            logging.error('[%s] Process miss start command' % self.id) | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            raise RuntimeError('Miss start command') | 
					 | 
					 | 
					            raise processException('Miss start command') | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        if self.__process is not None and self.__process.poll() is None:  # ERROR CASE | 
					 | 
					 | 
					        if self.__process is not None and self.__process.poll() is None:  # ERROR CASE | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            logging.error('[%s] Process is still running' % self.id) | 
					 | 
					 | 
					            logging.error('[%s] Process try to start but it is running' % self.id) | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            raise RuntimeError('Process is still running') | 
					 | 
					 | 
					            raise processException('Process is still running') | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        if self.env is not None and 'PATH' not in self.env and '/' not in self.cmd[0]:  # WARNING CASE | 
					 | 
					 | 
					        if self.env is not None and 'PATH' not in self.env and '/' not in self.cmd[0]:  # WARNING CASE | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            logging.warning('[%s] Executable file in relative path but miss PATH in environ' % self.id) | 
					 | 
					 | 
					            logging.warning('[%s] Executable file in relative path but miss PATH in environ' % self.id) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if self.file is not None:  # create and write file contents | 
					 | 
					 | 
					        if self.file is not None:  # create and write file contents | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -153,11 +154,15 @@ class Process(object): | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        else:  # discard all the output of sub process | 
					 | 
					 | 
					        else:  # discard all the output of sub process | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            stdout = DEVNULL | 
					 | 
					 | 
					            stdout = DEVNULL | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            stderr = DEVNULL | 
					 | 
					 | 
					            stderr = DEVNULL | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        self.__process = Popen( | 
					 | 
					 | 
					        try: | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            self.cmd, env = self.env, | 
					 | 
					 | 
					            self.__process = Popen( | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            stdout = stdout, stderr = stderr, | 
					 | 
					 | 
					                self.cmd, env = self.env, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            preexec_fn = None if libcPath is None else Process.__preExec | 
					 | 
					 | 
					                stdout = stdout, stderr = stderr, | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        ) | 
					 | 
					 | 
					                preexec_fn = None if libcPath is None else Process.__preExec | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            ) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        except Exception as exp: | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            logging.error('[%s] Process unable to start -> %s' % (self.id, exp)) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            raise processException('Unable to start process') | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        logging.info('[%s] Process running -> PID = %i' % (self.id, self.__process.pid)) | 
					 | 
					 | 
					        logging.info('[%s] Process running -> PID = %i' % (self.id, self.__process.pid)) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    def signal(self, signalNum: int) -> None:  # send specified signal to sub process | 
					 | 
					 | 
					    def signal(self, signalNum: int) -> None:  # send specified signal to sub process | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |