Be safer before TERMing pids, actually use the override options passed
authorMahlon E. Smith <mahlon@martini.nu>
Wed, 28 May 2014 11:39:58 -0700
changeset 7 4321943b8db5
parent 6 5afabb9d8a2c
child 8 01c2ba6b0a44
Be safer before TERMing pids, actually use the override options passed from the payload, if any.
lib/symphony/tasks/ssh.rb
--- a/lib/symphony/tasks/ssh.rb	Thu May 22 11:38:59 2014 -0700
+++ b/lib/symphony/tasks/ssh.rb	Wed May 28 11:39:58 2014 -0700
@@ -137,7 +137,7 @@
 
 		cmd = []
 		cmd << Symphony::Task::SSH.path
-		cmd += Symphony::Task::SSH.opts
+		cmd += opts
 
 		cmd << '-p' << port.to_s
 		cmd << '-i' << key if key
@@ -162,7 +162,8 @@
 
 	ensure
 		if pid
-			Process.kill( :TERM, pid )
+			active = Process.kill( 0, pid ) rescue false
+			Process.kill( :TERM, pid ) if active
 			pid, status = Process.waitpid2( pid )
 		end
 		return status