Fix errno not defined [closes GH-465]
This commit is contained in:
parent
a42ab2ce20
commit
cf115c10b1
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue