From eec8c167cb07c52b0372a519709f8009c0757fa3 Mon Sep 17 00:00:00 2001 From: Adam Sawyer Date: Tue, 13 Mar 2012 14:41:58 -0400 Subject: [PATCH] When running in a jvm, get the OK name and version from java's system properties, to avoid exec'ing uname. --- lib/google/api_client/environment.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/google/api_client/environment.rb b/lib/google/api_client/environment.rb index 9faa28f7d..bc49788af 100644 --- a/lib/google/api_client/environment.rb +++ b/lib/google/api_client/environment.rb @@ -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