原來,我也陷入了問題,主要是因爲我想打印器一起生產線,因爲他們發生的事情,也有超時,會做一個kill -2
鼓勵加工清理。
最後,我結束了開始一個新的線程旁邊的POPEN通話(但在此之前,我開始打印的命令的東西),那裏的線程將調用kill -2
一旦POPEN電話比我的等待時間需要較長的時間:
Thread.new do
$next_thread += 1
this_thread = $next_thread - 1
$active_threads[this_thread] = true
start_time = Time.now
while true
break if not $active_threads[this_thread]
minutes_elapsed = (Time.now - start_time)/60
if minutes_elapsed > 90
inner_packer_pid = `ps -Af | tr -s ' ' | grep -v "grep" | grep "packer build" | cut -d' ' -f2 | sort | tail -n 1`.strip()
`kill -2 #{inner_packer_pid}`
cancel_build()
break
end
end
$active_threads[this_thread] = false
end
builders = Set.new
packer_build = IO.popen("packer build -color=#{not $is_no_color} #{spec_file} 2>&1")
$packer_build_pid = packer_build.pid
packer_build.each do |line|
puts line
end
這工作在停止popen呼叫,但它本質上用-9信號調用它。我需要-2,因爲進程需要運行一些內部清理... – ldanielw1