1515def generate_ssh_cmd (host , user , exec_cmd , private_key_path = None ):
1616 exec_cmd = exec_cmd .replace ('$' , '\\ $' )
1717 if private_key_path is None :
18- cmd = "ssh -o StrictHostKeyChecking=no {}@{} \" {}\" " .format (user , host , exec_cmd )
18+ cmd = "ssh -tt - o StrictHostKeyChecking=no {}@{} \" {}\" " .format (user , host , exec_cmd )
1919 else :
20- cmd = "ssh -o StrictHostKeyChecking=no -i {} {}@{} \" {}\" " .format (private_key_path , user , host , exec_cmd )
20+ cmd = "ssh -tt - o StrictHostKeyChecking=no -i {} {}@{} \" {}\" " .format (private_key_path , user , host , exec_cmd )
2121 return cmd
2222
2323
@@ -28,7 +28,7 @@ def __init__(self, user, host, cmd, workspace="~", private_key_path=None, output
2828 if output_file is not None :
2929 self .output_file = output_file
3030 with open (self .output_file , "wb" ) as out :
31- self .proc = subprocess .Popen (self .cmd , shell = True , stdout = out , stderr = out , bufsize = 1 )
31+ self .proc = subprocess .Popen (self .cmd , shell = True , stdin = subprocess . PIPE , stdout = out , stderr = out , bufsize = 1 )
3232 else :
3333 self .proc = subprocess .Popen (self .cmd , shell = True )
3434
@@ -37,7 +37,8 @@ def pid(self):
3737
3838 def kill (self ):
3939 # os.killpg(os.getpgid(self.proc.pid), signal.SIGKILL)
40- os .kill (self .proc .pid , signal .SIGKILL )
40+ # os.kill(self.proc.pid, signal.SIGKILL)
41+ self .proc .send_signal (signal .SIGINT )
4142
4243 def get_return_code (self ):
4344 self .proc .wait ()
0 commit comments