Fix errno not defined [closes GH-465]

This commit is contained in:
Mitchell Hashimoto 2011-08-13 18:54:32 -07:00
parent a42ab2ce20
commit cf115c10b1
1 changed files with 8 additions and 1 deletions

View File

@ -8,13 +8,20 @@ module Vagrant
# forking.
module SafeExec
def safe_exec(command)
# Create a list of things to rescue from. Since this is OS
# specific, we need to do some defined? checks here to make
# sure they exist.
rescue_from = []
rescue_from << Errno::EOPNOTSUPP if defined?(Errno::EOPNOTSUPP)
rescue_from << Errno::E045 if defined?(Errno::E045)
fork_instead = false
begin
pid = nil
pid = fork if fork_instead
Kernel.exec(command) if pid.nil?
Process.wait(pid) if pid
rescue Errno::E045
rescue *rescue_from
# We retried already, raise the issue and be done
raise if fork_instead