Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for jRuby + Windows #43

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jruby-1.7.24
Binary file added lib/jna-platform.jar
Binary file not shown.
Binary file added lib/jna.jar
Binary file not shown.
23 changes: 20 additions & 3 deletions lib/systemu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
[
Expand Down
30 changes: 9 additions & 21 deletions systemu.gemspec
Original file line number Diff line number Diff line change
@@ -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(*[])

Expand Down