mirror of
				https://github.com/YosysHQ/sby.git
				synced 2025-11-04 14:49:13 +00:00 
			
		
		
		
	use a console process group and send ctrl+break signal instead
This commit is contained in:
		
							parent
							
								
									7ac54c6a2e
								
							
						
					
					
						commit
						031cdb8df3
					
				
					 1 changed files with 5 additions and 4 deletions
				
			
		| 
						 | 
					@ -118,11 +118,12 @@ class SbyTask:
 | 
				
			||||||
                self.job.log("{}: terminating process".format(self.info))
 | 
					                self.job.log("{}: terminating process".format(self.info))
 | 
				
			||||||
            if os.name != "posix":
 | 
					            if os.name != "posix":
 | 
				
			||||||
                # self.p.terminate does not actually terminate underlying
 | 
					                # self.p.terminate does not actually terminate underlying
 | 
				
			||||||
                # processes on Windows, so we resort to using the WinAPI to
 | 
					                # processes on Windows, so send ctrl+break to the process
 | 
				
			||||||
                # kill the shell and children. This for some reason does
 | 
					                # group we created. This for some reason does
 | 
				
			||||||
                # not cause the associated future (self.fut) to complete
 | 
					                # not cause the associated future (self.fut) to complete
 | 
				
			||||||
                # until it is awaited on one last time.
 | 
					                # until it is awaited on one last time.
 | 
				
			||||||
                win_killpg.win_killpg(self.p.pid)
 | 
					
 | 
				
			||||||
 | 
					                os.kill(self.p.pid, signal.CTRL_BREAK_EVENT)
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                try:
 | 
					                try:
 | 
				
			||||||
                    os.killpg(self.p.pid, signal.SIGTERM)
 | 
					                    os.killpg(self.p.pid, signal.SIGTERM)
 | 
				
			||||||
| 
						 | 
					@ -165,7 +166,7 @@ class SbyTask:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                subp_kwargs = { "preexec_fn" : preexec_fn }
 | 
					                subp_kwargs = { "preexec_fn" : preexec_fn }
 | 
				
			||||||
            else:
 | 
					            else:
 | 
				
			||||||
                subp_kwargs = {}
 | 
					                subp_kwargs = { "creationflags" : subprocess.CREATE_NEW_PROCESS_GROUP }
 | 
				
			||||||
            self.p = await asyncio.create_subprocess_shell(self.cmdline, stdin=asyncio.subprocess.DEVNULL,
 | 
					            self.p = await asyncio.create_subprocess_shell(self.cmdline, stdin=asyncio.subprocess.DEVNULL,
 | 
				
			||||||
                    stdout=asyncio.subprocess.PIPE,
 | 
					                    stdout=asyncio.subprocess.PIPE,
 | 
				
			||||||
                    stderr=(asyncio.subprocess.STDOUT if self.logstderr else None),
 | 
					                    stderr=(asyncio.subprocess.STDOUT if self.logstderr else None),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue