childprocess 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/childprocess.rb +7 -5
- data/lib/childprocess/jruby.rb +2 -2
- data/lib/childprocess/jruby/pump.rb +1 -0
- data/lib/childprocess/tools/generator.rb +2 -3
- data/lib/childprocess/unix/platform/i386-solaris.rb +11 -0
- data/lib/childprocess/version.rb +1 -1
- data/lib/childprocess/windows/lib.rb +2 -2
- data/lib/childprocess/windows/process_builder.rb +5 -1
- data/spec/childprocess_spec.rb +3 -1
- data/spec/io_spec.rb +21 -0
- data/spec/spec_helper.rb +1 -1
- metadata +6 -5
data/lib/childprocess.rb
CHANGED
@@ -11,7 +11,7 @@ module ChildProcess
|
|
11
11
|
class << self
|
12
12
|
def new(*args)
|
13
13
|
case os
|
14
|
-
when :macosx, :linux, :
|
14
|
+
when :macosx, :linux, :solaris, :bsd, :cygwin
|
15
15
|
if posix_spawn?
|
16
16
|
Unix::PosixSpawnProcess.new(args)
|
17
17
|
elsif jruby?
|
@@ -22,7 +22,7 @@ module ChildProcess
|
|
22
22
|
when :windows
|
23
23
|
Windows::Process.new(args)
|
24
24
|
else
|
25
|
-
raise Error, "unsupported platform #{
|
25
|
+
raise Error, "unsupported platform #{platform_name.inspect}"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
alias_method :build, :new
|
@@ -101,8 +101,10 @@ module ChildProcess
|
|
101
101
|
:windows
|
102
102
|
when /cygwin/
|
103
103
|
:cygwin
|
104
|
-
when /solaris|
|
105
|
-
:
|
104
|
+
when /solaris|sunos/
|
105
|
+
:solaris
|
106
|
+
when /bsd/
|
107
|
+
:bsd
|
106
108
|
else
|
107
109
|
raise Error, "unknown os: #{host_os.inspect}"
|
108
110
|
end
|
@@ -144,7 +146,7 @@ module ChildProcess
|
|
144
146
|
elsif windows?
|
145
147
|
Windows::Lib.dont_inherit file
|
146
148
|
else
|
147
|
-
raise Error, "not sure how to set close-on-exec for #{file.inspect} on #{
|
149
|
+
raise Error, "not sure how to set close-on-exec for #{file.inspect} on #{platform_name.inspect}"
|
148
150
|
end
|
149
151
|
end
|
150
152
|
|
data/lib/childprocess/jruby.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'ffi'
|
2
1
|
require 'fileutils'
|
3
2
|
|
4
3
|
module ChildProcess
|
@@ -120,8 +119,8 @@ int main() {
|
|
120
119
|
end
|
121
120
|
|
122
121
|
def result
|
123
|
-
if @sizeof.empty?
|
124
|
-
raise "no
|
122
|
+
if @sizeof.empty? && @constants.empty?
|
123
|
+
raise "no data collected, nothing to do"
|
125
124
|
end
|
126
125
|
|
127
126
|
out = ['module ChildProcess::Unix::Platform']
|
data/lib/childprocess/version.rb
CHANGED
@@ -138,12 +138,12 @@ module ChildProcess
|
|
138
138
|
attach_function :terminate_process, :TerminateProcess, [:pointer, :uint], :bool
|
139
139
|
|
140
140
|
#
|
141
|
-
#
|
141
|
+
# intptr_t _get_osfhandle(
|
142
142
|
# int fd
|
143
143
|
# );
|
144
144
|
#
|
145
145
|
|
146
|
-
attach_function :get_osfhandle, :_get_osfhandle, [:int], :
|
146
|
+
attach_function :get_osfhandle, :_get_osfhandle, [:int], :intptr_t
|
147
147
|
|
148
148
|
#
|
149
149
|
# int _open_osfhandle (
|
@@ -72,7 +72,7 @@ module ChildProcess
|
|
72
72
|
@inherit, # inherit handles
|
73
73
|
@flags, # creation flags
|
74
74
|
@env_ptr, # environment
|
75
|
-
|
75
|
+
cwd, # current directory
|
76
76
|
startup_info, # startup info
|
77
77
|
process_info # process info
|
78
78
|
)
|
@@ -94,6 +94,10 @@ module ChildProcess
|
|
94
94
|
@flags |= DETACHED_PROCESS if @detach
|
95
95
|
end
|
96
96
|
|
97
|
+
def cwd
|
98
|
+
@cwd ||= FFI::MemoryPointer.from_string(Dir.pwd)
|
99
|
+
end
|
100
|
+
|
97
101
|
def setup_io
|
98
102
|
if @stdout || @stderr
|
99
103
|
startup_info[:dwFlags] ||= 0
|
data/spec/childprocess_spec.rb
CHANGED
@@ -138,14 +138,16 @@ describe ChildProcess do
|
|
138
138
|
process = ruby("print Dir.pwd")
|
139
139
|
process.io.stdout = process.io.stderr = file
|
140
140
|
|
141
|
+
expected_dir = nil
|
141
142
|
Dir.chdir(Dir.tmpdir) do
|
143
|
+
expected_dir = Dir.pwd
|
142
144
|
process.start
|
143
145
|
end
|
144
146
|
|
145
147
|
process.wait
|
146
148
|
|
147
149
|
file.rewind
|
148
|
-
file.read.should ==
|
150
|
+
file.read.should == expected_dir
|
149
151
|
end
|
150
152
|
end
|
151
153
|
|
data/spec/io_spec.rb
CHANGED
@@ -128,4 +128,25 @@ describe ChildProcess do
|
|
128
128
|
|
129
129
|
wait_until { can_bind? "127.0.0.1", port }
|
130
130
|
end
|
131
|
+
|
132
|
+
it "handles long output" do
|
133
|
+
process = ruby <<-CODE
|
134
|
+
print 'a'*3000
|
135
|
+
CODE
|
136
|
+
|
137
|
+
out = Tempfile.new("long-output")
|
138
|
+
out.sync = true
|
139
|
+
|
140
|
+
begin
|
141
|
+
process.io.stdout = out
|
142
|
+
|
143
|
+
process.start
|
144
|
+
process.wait
|
145
|
+
|
146
|
+
out.rewind
|
147
|
+
out.read.size.should == 3000
|
148
|
+
ensure
|
149
|
+
out.close
|
150
|
+
end
|
151
|
+
end
|
131
152
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -151,7 +151,7 @@ RSpec.configure do |c|
|
|
151
151
|
@process && @process.alive? && @process.stop
|
152
152
|
}
|
153
153
|
|
154
|
-
if ChildProcess.jruby? &&
|
154
|
+
if ChildProcess.jruby? && ChildProcess.new("true").instance_of?(ChildProcess::JRuby::Process)
|
155
155
|
c.filter_run_excluding :process_builder => false
|
156
156
|
end
|
157
157
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: childprocess
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 1
|
10
|
+
version: 0.3.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jari Bakken
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-02-05 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rspec
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/childprocess/unix/io.rb
|
113
113
|
- lib/childprocess/unix/lib.rb
|
114
114
|
- lib/childprocess/unix/platform/i386-linux.rb
|
115
|
+
- lib/childprocess/unix/platform/i386-solaris.rb
|
115
116
|
- lib/childprocess/unix/platform/x86_64-linux.rb
|
116
117
|
- lib/childprocess/unix/platform/x86_64-macosx.rb
|
117
118
|
- lib/childprocess/unix/posix_spawn_process.rb
|
@@ -161,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
162
|
requirements: []
|
162
163
|
|
163
164
|
rubyforge_project: childprocess
|
164
|
-
rubygems_version: 1.8.
|
165
|
+
rubygems_version: 1.8.15
|
165
166
|
signing_key:
|
166
167
|
specification_version: 3
|
167
168
|
summary: This gem aims at being a simple and reliable solution for controlling external programs running in the background on any Ruby / OS combination.
|