lib/symphony/tasks/ssh.rb
changeset 7 4321943b8db5
parent 6 5afabb9d8a2c
child 11 ffa70066522c
equal deleted inserted replaced
6:5afabb9d8a2c 7:4321943b8db5
   135 		user = payload[ 'user' ] || Symphony::Task::SSH.user
   135 		user = payload[ 'user' ] || Symphony::Task::SSH.user
   136 		key  = payload[ 'key'  ] || Symphony::Task::SSH.key
   136 		key  = payload[ 'key'  ] || Symphony::Task::SSH.key
   137 
   137 
   138 		cmd = []
   138 		cmd = []
   139 		cmd << Symphony::Task::SSH.path
   139 		cmd << Symphony::Task::SSH.path
   140 		cmd += Symphony::Task::SSH.opts
   140 		cmd += opts
   141 
   141 
   142 		cmd << '-p' << port.to_s
   142 		cmd << '-p' << port.to_s
   143 		cmd << '-i' << key if key
   143 		cmd << '-i' << key if key
   144 		cmd << '-l' << user
   144 		cmd << '-l' << user
   145 		cmd << payload[ 'host' ]
   145 		cmd << payload[ 'host' ]
   160 
   160 
   161 		status = nil
   161 		status = nil
   162 
   162 
   163 	ensure
   163 	ensure
   164 		if pid
   164 		if pid
   165 			Process.kill( :TERM, pid )
   165 			active = Process.kill( 0, pid ) rescue false
       
   166 			Process.kill( :TERM, pid ) if active
   166 			pid, status = Process.waitpid2( pid )
   167 			pid, status = Process.waitpid2( pid )
   167 		end
   168 		end
   168 		return status
   169 		return status
   169 	end
   170 	end
   170 
   171