1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-30 22:50:10 +03:00

B : Pass Local/SSHCommand terminator thread error via variable ()

This commit is contained in:
Vlastimil Holer 2018-05-03 16:31:38 +02:00 committed by Ruben S. Montero
parent 0fa65069a4
commit 3b3c9643a8

@ -135,6 +135,9 @@ private
e.binmode
end
terminator_e = nil
mutex = Mutex.new
out_reader = Thread.new { o.read }
err_reader = Thread.new { e.read }
terminator = Thread.new {
@ -148,11 +151,14 @@ private
if pid
begin
sleep @timeout
Process.kill('TERM', pid)
rescue
mutex.synchronize do
terminator_e = Timeout::Error
end
ensure
end
raise Timeout::Error
Process.kill('TERM', pid)
end
end
}
@ -162,8 +168,9 @@ private
out = [out_reader.value, err_reader.value, t.value]
mutex.lock
terminator.kill
terminator.value
raise terminator_e if terminator_e
out
}