childprocess 0.5.0 → 0.5.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.
- checksums.yaml +4 -4
- data/lib/childprocess/unix/posix_spawn_process.rb +9 -11
- data/lib/childprocess/version.rb +1 -1
- data/spec/io_spec.rb +11 -0
- data/spec/spec_helper.rb +21 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a69d7a6d2d1a65d1496d2b2dc327348cfdf6801
|
4
|
+
data.tar.gz: ec705f40bd0330bea05aa4ed556e047fa8cdf337
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 474cbc9d237b873332e387e602b575628c49479cb60705509fc154dd35b5409fe1b48d2b8b9d5b5775d72b5b3787359cde2b9f35a37fb5834a444efb327b0002
|
7
|
+
data.tar.gz: a25cb4f8d10b38537b101484bebf8888530020ff3876615d4daa5b78ee96b104758973f0e15b2f2e97e50cd82fd5de532d4bff1352a3bcc47d7497dafd0ac745
|
@@ -13,18 +13,16 @@ module ChildProcess
|
|
13
13
|
actions = Lib::FileActions.new
|
14
14
|
attrs = Lib::Attrs.new
|
15
15
|
|
16
|
-
if
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
16
|
+
if io.stdout
|
17
|
+
actions.add_dup fileno_for(io.stdout), fileno_for($stdout)
|
18
|
+
else
|
19
|
+
actions.add_open fileno_for($stdout), "/dev/null", File::WRONLY, 0644
|
20
|
+
end
|
22
21
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
end
|
22
|
+
if io.stderr
|
23
|
+
actions.add_dup fileno_for(io.stderr), fileno_for($stderr)
|
24
|
+
else
|
25
|
+
actions.add_open fileno_for($stderr), "/dev/null", File::WRONLY, 0644
|
28
26
|
end
|
29
27
|
|
30
28
|
if duplex?
|
data/lib/childprocess/version.rb
CHANGED
data/spec/io_spec.rb
CHANGED
@@ -204,4 +204,15 @@ describe ChildProcess do
|
|
204
204
|
out.close
|
205
205
|
end
|
206
206
|
end
|
207
|
+
|
208
|
+
it 'should not inherit stdout and stderr by default' do
|
209
|
+
cap = capture_std do
|
210
|
+
process = echo
|
211
|
+
process.start
|
212
|
+
process.wait
|
213
|
+
end
|
214
|
+
|
215
|
+
expect(cap.stdout).to eq ''
|
216
|
+
expect(cap.stderr).to eq ''
|
217
|
+
end
|
207
218
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -11,6 +11,7 @@ require 'rspec'
|
|
11
11
|
require 'tempfile'
|
12
12
|
require 'socket'
|
13
13
|
require 'stringio'
|
14
|
+
require 'ostruct'
|
14
15
|
|
15
16
|
module ChildProcessSpecHelper
|
16
17
|
RUBY = defined?(Gem) ? Gem.ruby : 'ruby'
|
@@ -212,6 +213,26 @@ module ChildProcessSpecHelper
|
|
212
213
|
end
|
213
214
|
end
|
214
215
|
|
216
|
+
def capture_std
|
217
|
+
orig_out = STDOUT.clone
|
218
|
+
orig_err = STDERR.clone
|
219
|
+
|
220
|
+
out = Tempfile.new 'captured-stdout'
|
221
|
+
err = Tempfile.new 'captured-stderr'
|
222
|
+
out.sync = true
|
223
|
+
err.sync = true
|
224
|
+
|
225
|
+
STDOUT.reopen out
|
226
|
+
STDERR.reopen err
|
227
|
+
|
228
|
+
yield
|
229
|
+
|
230
|
+
OpenStruct.new stdout: rewind_and_read(out), stderr: rewind_and_read(err)
|
231
|
+
ensure
|
232
|
+
STDOUT.reopen orig_out
|
233
|
+
STDERR.reopen orig_err
|
234
|
+
end
|
235
|
+
|
215
236
|
end # ChildProcessSpecHelper
|
216
237
|
|
217
238
|
Thread.abort_on_exception = true
|