diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..3361fb0 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +jruby-1.7.24 diff --git a/lib/jna-platform.jar b/lib/jna-platform.jar new file mode 100644 index 0000000..f3a9fd2 Binary files /dev/null and b/lib/jna-platform.jar differ diff --git a/lib/jna.jar b/lib/jna.jar new file mode 100644 index 0000000..a943670 Binary files /dev/null and b/lib/jna.jar differ diff --git a/lib/systemu.rb b/lib/systemu.rb index 5f7745a..595f6b9 100644 --- a/lib/systemu.rb +++ b/lib/systemu.rb @@ -291,9 +291,26 @@ def systemu StreamReader.new(stream) end - field = process.get_class.get_declared_field("pid") - field.set_accessible(true) - pid = field.get(process) + pid = nil + if process.get_class.get_name == "java.lang.UNIXProcess" + field = process.get_class.get_declared_field("pid") + field.set_accessible(true) + pid = field.get_int(process) + else + # Import java classes + java_import com.sun.jna.Pointer + java_import com.sun.jna.platform.win32.Kernel32 + java_import com.sun.jna.platform.win32.WinNT + + field = process.get_class.get_declared_field("handle") + field.set_accessible(true) + handl = field.get_long(process) + + krnl = Kernel32.INSTANCE + handle = WinNT::HANDLE.new + handle.setPointer(Pointer.createConstant(handl)) + pid = krnl.GetProcessId(handle) + end thread = new_thread pid, @block if @block exit_code = process.wait_for [ diff --git a/systemu.gemspec b/systemu.gemspec index bfe834c..b4b869e 100644 --- a/systemu.gemspec +++ b/systemu.gemspec @@ -1,40 +1,28 @@ ## systemu.gemspec # +$:.push File.expand_path("../lib", __FILE__) + Gem::Specification::new do |spec| spec.name = "systemu" - spec.version = "2.6.4" + spec.version = "2.6.6" spec.platform = Gem::Platform::RUBY spec.summary = "systemu" spec.description = "universal capture of stdout and stderr and handling of child process pid for windows, *nix, etc." spec.license = "Ruby" - spec.files = -["LICENSE", - "README", - "README.erb", - "Rakefile", - "lib", - "lib/systemu.rb", - "samples", - "samples/a.rb", - "samples/b.rb", - "samples/c.rb", - "samples/d.rb", - "samples/e.rb", - "samples/f.rb", - "systemu.gemspec", - "test", - "test/systemu_test.rb", - "test/testing.rb"] + spec.files = `git ls-files`.split("\n"). + select { |f| f =~ /^(lib)/ || + f =~ /^History|LICENSE|README|Rakefile|Mavenfile|pom.xml/i } + + Dir.glob('lib/**/*.jar') # 'lib/jopenssl.jar' and potentially BC jars spec.executables = [] - + spec.require_path = "lib" spec.test_files = nil - + spec.extensions.push(*[])