mirror of
				https://github.com/ARM-software/devlib.git
				synced 2025-11-03 23:41:21 +00:00 
			
		
		
		
	connection: kill spawned child subprocesses:
Subprocesses that were spawned under the same pgid were not necessarily being terminated when the parent was terminated, allowing them to continue running. This change explicitly kills the process group involved.
This commit is contained in:
		
				
					committed by
					
						
						Marc Bonnici
					
				
			
			
				
	
			
			
			
						parent
						
							0498017bf0
						
					
				
				
					commit
					dc7faf46e4
				
			@@ -203,11 +203,11 @@ class PopenBackgroundCommand(BackgroundCommand):
 | 
			
		||||
 | 
			
		||||
    def cancel(self, kill_timeout=_KILL_TIMEOUT):
 | 
			
		||||
        popen = self.popen
 | 
			
		||||
        popen.send_signal(signal.SIGTERM)
 | 
			
		||||
        os.killpg(os.getpgid(popen.pid), signal.SIGTERM)
 | 
			
		||||
        try:
 | 
			
		||||
            popen.wait(timeout=_KILL_TIMEOUT)
 | 
			
		||||
        except subprocess.TimeoutExpired:
 | 
			
		||||
            popen.kill()
 | 
			
		||||
            os.killpg(os.getpgid(popen.pid), signal.SIGKILL)
 | 
			
		||||
 | 
			
		||||
    def close(self):
 | 
			
		||||
        self.popen.__exit__(None, None, None)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user