Lock around chdir in Subprocess for thread safety
This commit is contained in:
parent
c84c609633
commit
bd60d6b283
|
@ -1,3 +1,5 @@
|
|||
require 'thread'
|
||||
|
||||
require 'childprocess'
|
||||
require 'log4r'
|
||||
|
||||
|
@ -12,6 +14,8 @@ module Vagrant
|
|||
# from the subprocess in real time, by simply passing a block to
|
||||
# the execute method.
|
||||
class Subprocess
|
||||
@@chdir_lock = Mutex.new
|
||||
|
||||
# The chunk size for reading from subprocess IO.
|
||||
READ_CHUNK_SIZE = 4096
|
||||
|
||||
|
@ -72,8 +76,10 @@ module Vagrant
|
|||
|
||||
# Start the process
|
||||
begin
|
||||
Dir.chdir(workdir) do
|
||||
process.start
|
||||
@@chdir_lock.synchronize do
|
||||
Dir.chdir(workdir) do
|
||||
process.start
|
||||
end
|
||||
end
|
||||
rescue ChildProcess::LaunchError => ex
|
||||
# Raise our own version of the error so that users of the class
|
||||
|
|
|
@ -7,6 +7,7 @@ module VagrantPlugins
|
|||
end
|
||||
|
||||
def call(env)
|
||||
raise "foo"
|
||||
env[:ui].info I18n.t("vagrant.actions.vm.import.importing",
|
||||
:name => env[:machine].box.name)
|
||||
|
||||
|
|
Loading…
Reference in New Issue