diff --git a/chef/lib/chef/provider/erl_call.rb b/chef/lib/chef/provider/erl_call.rb index 0f2be3e94c0..4ab621a6ba5 100644 --- a/chef/lib/chef/provider/erl_call.rb +++ b/chef/lib/chef/provider/erl_call.rb @@ -55,22 +55,26 @@ def action_run command = "erl_call -e #{distributed} #{node} #{cookie}" - pid, stdin, stdout, stderr = popen4(command, :waitlast => true) - - Chef::Log.debug("Running erl_call[#{@new_resource.name}]") - Chef::Log.debug("erl_call[#{@new_resource.name}] command: #{command}") - Chef::Log.debug("erl_call[#{@new_resource.name}] code: #{@new_resource.code}") - - @new_resource.code.each_line { |line| stdin.puts "#{line.chomp!}" } - stdin.close - - Chef::Log.info("Ran erl_call[#{@new_resource.name}] successfully") - Chef::Log.debug("erl_call[#{@new_resource.name}] output: ") - - stdout.each_line { |line| Chef::Log.debug("#{line}")} - stderr.each_line { |line| Chef::Log.debug("#{line}")} - stdout.close - stderr.close + begin + pid, stdin, stdout, stderr = popen4(command, :waitlast => true) + + Chef::Log.debug("Running erl_call[#{@new_resource.name}]") + Chef::Log.debug("erl_call[#{@new_resource.name}] command: #{command}") + Chef::Log.debug("erl_call[#{@new_resource.name}] code: #{@new_resource.code}") + + @new_resource.code.each_line { |line| stdin.puts "#{line.chomp!}" } + stdin.close + + Chef::Log.info("Ran erl_call[#{@new_resource.name}] successfully") + Chef::Log.debug("erl_call[#{@new_resource.name}] output: ") + + stdout.each_line { |line| Chef::Log.debug("#{line}")} + stderr.each_line { |line| Chef::Log.debug("#{line}")} + stdout.close + stderr.close + ensure + Process.wait(pid) if pid + end end