When running in a jvm, get the OK name and version from java's system properties, to avoid exec'ing uname.

This commit is contained in:
Adam Sawyer 2012-03-13 14:41:58 -04:00
parent 7545efddb6
commit eec8c167cb
1 changed files with 7 additions and 0 deletions

View File

@ -24,6 +24,13 @@ module Google
`ver`.sub(/\s*\[Version\s*/, '/').sub(']', '').strip
elsif RUBY_PLATFORM =~ /darwin/i
"Mac OS X/#{`sw_vers -productVersion`}"
elsif RUBY_PLATFORM == 'java'
# Get the information from java system properties to avoid spawning a
# sub-process, which is not friendly in some contexts (web servers).
require 'java'
name = java.lang.System.getProperty('os.name')
version = java.lang.System.getProperty('os.version')
"#{name} #{version}"
else
`uname -sr`.sub(' ', '/')
end