Skip to content

Commit

Permalink
ensure we wait for the pid to die before moving on
Browse files Browse the repository at this point in the history
  • Loading branch information
joewilliams committed Oct 20, 2010
1 parent 973d8a6 commit 9b86531
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions chef/lib/chef/provider/erl_call.rb
Expand Up @@ -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

Expand Down

0 comments on commit 9b86531

Please sign in to comment.