Merge pull request #9470 from briancain/subprocess-frozen-windows-ps

Pass ruby block to capture stdout when determining PS version
This commit is contained in:
Brian Cain 2018-02-22 12:56:28 -08:00 committed by GitHub
commit bba4978c13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -11,6 +11,7 @@ module Vagrant
class PowerShell class PowerShell
# NOTE: Version checks are only on Major # NOTE: Version checks are only on Major
MINIMUM_REQUIRED_VERSION = 3 MINIMUM_REQUIRED_VERSION = 3
LOGGER = Log4r::Logger.new("vagrant::util::powershell")
# @return [Boolean] powershell executable available on PATH # @return [Boolean] powershell executable available on PATH
def self.available? def self.available?
@ -85,8 +86,14 @@ module Vagrant
"Write-Output $PSVersionTable.PSVersion.Major" "Write-Output $PSVersionTable.PSVersion.Major"
].flatten ].flatten
r = Subprocess.execute(*command) version = nil
@_powershell_version = r.exit_code != 0 ? nil : r.stdout.chomp begin
r = Subprocess.execute(*command, notify: [:stdout, :stderr], timeout: 10) {|io_name,data| version = data}
rescue Vagrant::Util::Subprocess::TimeoutExceeded
LOGGER.debug("Timeout exceeded while attempting to determine version of Powershell.")
end
@_powershell_version = version
end end
@_powershell_version @_powershell_version
end end