fork
+ exec
= spawn
This commit is contained in:
parent
2807f88212
commit
8c884a2e8c
3 changed files with 6 additions and 3 deletions
|
@ -68,7 +68,7 @@ module Vagrant
|
|||
redir_cmd = "sudo redir --laddr=127.0.0.1 --lport=#{host} --cport=#{guest} --caddr=#{@container_ip} 2>/dev/null"
|
||||
|
||||
@logger.debug "Forwarding port with `#{redir_cmd}`"
|
||||
fork { exec redir_cmd }
|
||||
spawn redir_cmd
|
||||
end
|
||||
|
||||
def store_redir_pid(host_port, redir_pid)
|
||||
|
|
|
@ -22,14 +22,14 @@ describe Vagrant::LXC::Action::ForwardPorts do
|
|||
machine.stub(provider: provider, data_dir: data_dir)
|
||||
|
||||
subject.stub(exec: true)
|
||||
subject.stub(:fork) { |&block| block.call; pid }
|
||||
subject.stub(spawn: pid)
|
||||
subject.call(env)
|
||||
end
|
||||
|
||||
after { FileUtils.rm_rf data_dir.to_s }
|
||||
|
||||
it 'forwards ports using redir' do
|
||||
subject.should have_received(:exec).with(
|
||||
subject.should have_received(:spawn).with(
|
||||
"sudo redir --laddr=127.0.0.1 --lport=#{host_port} --cport=#{guest_port} --caddr=#{container_ip} 2>/dev/null"
|
||||
)
|
||||
end
|
||||
|
|
|
@ -14,6 +14,9 @@ module UnitExampleGroup
|
|||
Object.any_instance.stub(:fork) { |*args, &block|
|
||||
UnitExampleGroup.prevent_system_calls(*args, &block)
|
||||
}
|
||||
Object.any_instance.stub(:spawn) { |*args, &block|
|
||||
UnitExampleGroup.prevent_system_calls(*args, &block)
|
||||
}
|
||||
require 'vagrant/util/subprocess'
|
||||
Vagrant::Util::Subprocess.stub(:execute) { |*args, &block|
|
||||
UnitExampleGroup.prevent_system_calls(*args, &block)
|
||||
|
|
Loading…
Reference in a new issue