childprocess 1.0.0 → 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.document +6 -6
- data/.gitignore +28 -28
- data/.rspec +1 -1
- data/.travis.yml +37 -52
- data/CHANGELOG.md +83 -56
- data/Gemfile +9 -18
- data/LICENSE +20 -20
- data/README.md +230 -200
- data/Rakefile +61 -61
- data/appveyor.yml +36 -60
- data/childprocess.gemspec +26 -29
- data/lib/childprocess.rb +210 -210
- data/lib/childprocess/abstract_io.rb +36 -36
- data/lib/childprocess/abstract_process.rb +192 -192
- data/lib/childprocess/errors.rb +37 -37
- data/lib/childprocess/jruby.rb +56 -56
- data/lib/childprocess/jruby/io.rb +16 -16
- data/lib/childprocess/jruby/process.rb +184 -184
- data/lib/childprocess/jruby/pump.rb +53 -53
- data/lib/childprocess/tools/generator.rb +145 -145
- data/lib/childprocess/unix.rb +9 -9
- data/lib/childprocess/unix/fork_exec_process.rb +78 -70
- data/lib/childprocess/unix/io.rb +21 -21
- data/lib/childprocess/unix/lib.rb +186 -186
- data/lib/childprocess/unix/platform/arm64-macosx.rb +11 -0
- data/lib/childprocess/unix/platform/i386-linux.rb +12 -12
- data/lib/childprocess/unix/platform/i386-solaris.rb +11 -11
- data/lib/childprocess/unix/platform/x86_64-linux.rb +12 -12
- data/lib/childprocess/unix/platform/x86_64-macosx.rb +11 -11
- data/lib/childprocess/unix/posix_spawn_process.rb +134 -134
- data/lib/childprocess/unix/process.rb +90 -89
- data/lib/childprocess/version.rb +3 -3
- data/lib/childprocess/windows.rb +38 -33
- data/lib/childprocess/windows/handle.rb +91 -91
- data/lib/childprocess/windows/io.rb +25 -25
- data/lib/childprocess/windows/lib.rb +416 -416
- data/lib/childprocess/windows/process.rb +131 -130
- data/lib/childprocess/windows/process_builder.rb +178 -178
- data/lib/childprocess/windows/structs.rb +148 -148
- data/spec/abstract_io_spec.rb +12 -12
- data/spec/childprocess_spec.rb +447 -447
- data/spec/io_spec.rb +228 -228
- data/spec/jruby_spec.rb +24 -24
- data/spec/pid_behavior.rb +12 -12
- data/spec/platform_detection_spec.rb +86 -86
- data/spec/spec_helper.rb +270 -270
- data/spec/unix_spec.rb +57 -57
- data/spec/windows_spec.rb +23 -23
- metadata +12 -26
- data/ext/mkrf_conf.rb +0 -24
data/spec/unix_spec.rb
CHANGED
@@ -1,57 +1,57 @@
|
|
1
|
-
require File.expand_path('../spec_helper', __FILE__)
|
2
|
-
require "pid_behavior"
|
3
|
-
|
4
|
-
if ChildProcess.unix? && !ChildProcess.jruby? && !ChildProcess.posix_spawn?
|
5
|
-
|
6
|
-
describe ChildProcess::Unix::Process do
|
7
|
-
it_behaves_like "a platform that provides the child's pid"
|
8
|
-
|
9
|
-
it "handles ECHILD race condition where process dies between timeout and KILL" do
|
10
|
-
process = sleeping_ruby
|
11
|
-
|
12
|
-
allow(process).to receive(:fork).and_return('fakepid')
|
13
|
-
allow(process).to receive(:send_term)
|
14
|
-
allow(process).to receive(:poll_for_exit).and_raise(ChildProcess::TimeoutError)
|
15
|
-
allow(process).to receive(:send_kill).and_raise(Errno::ECHILD.new)
|
16
|
-
|
17
|
-
process.start
|
18
|
-
expect { process.stop }.not_to raise_error
|
19
|
-
|
20
|
-
allow(process).to receive(:alive?).and_return(false)
|
21
|
-
|
22
|
-
process.send(:send_signal, 'TERM')
|
23
|
-
end
|
24
|
-
|
25
|
-
it "handles ESRCH race condition where process dies between timeout and KILL" do
|
26
|
-
process = sleeping_ruby
|
27
|
-
|
28
|
-
allow(process).to receive(:fork).and_return('fakepid')
|
29
|
-
allow(process).to receive(:send_term)
|
30
|
-
allow(process).to receive(:poll_for_exit).and_raise(ChildProcess::TimeoutError)
|
31
|
-
allow(process).to receive(:send_kill).and_raise(Errno::ESRCH.new)
|
32
|
-
|
33
|
-
process.start
|
34
|
-
expect { process.stop }.not_to raise_error
|
35
|
-
|
36
|
-
allow(process).to receive(:alive?).and_return(false)
|
37
|
-
|
38
|
-
process.send(:send_signal, 'TERM')
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe ChildProcess::Unix::IO do
|
43
|
-
let(:io) { ChildProcess::Unix::IO.new }
|
44
|
-
|
45
|
-
it "raises an ArgumentError if given IO does not respond to :to_io" do
|
46
|
-
expect { io.stdout = nil }.to raise_error(ArgumentError, /to respond to :to_io/)
|
47
|
-
end
|
48
|
-
|
49
|
-
it "raises a TypeError if #to_io does not return an IO" do
|
50
|
-
fake_io = Object.new
|
51
|
-
def fake_io.to_io() StringIO.new end
|
52
|
-
|
53
|
-
expect { io.stdout = fake_io }.to raise_error(TypeError, /expected IO, got/)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
require "pid_behavior"
|
3
|
+
|
4
|
+
if ChildProcess.unix? && !ChildProcess.jruby? && !ChildProcess.posix_spawn?
|
5
|
+
|
6
|
+
describe ChildProcess::Unix::Process do
|
7
|
+
it_behaves_like "a platform that provides the child's pid"
|
8
|
+
|
9
|
+
it "handles ECHILD race condition where process dies between timeout and KILL" do
|
10
|
+
process = sleeping_ruby
|
11
|
+
|
12
|
+
allow(process).to receive(:fork).and_return('fakepid')
|
13
|
+
allow(process).to receive(:send_term)
|
14
|
+
allow(process).to receive(:poll_for_exit).and_raise(ChildProcess::TimeoutError)
|
15
|
+
allow(process).to receive(:send_kill).and_raise(Errno::ECHILD.new)
|
16
|
+
|
17
|
+
process.start
|
18
|
+
expect { process.stop }.not_to raise_error
|
19
|
+
|
20
|
+
allow(process).to receive(:alive?).and_return(false)
|
21
|
+
|
22
|
+
process.send(:send_signal, 'TERM')
|
23
|
+
end
|
24
|
+
|
25
|
+
it "handles ESRCH race condition where process dies between timeout and KILL" do
|
26
|
+
process = sleeping_ruby
|
27
|
+
|
28
|
+
allow(process).to receive(:fork).and_return('fakepid')
|
29
|
+
allow(process).to receive(:send_term)
|
30
|
+
allow(process).to receive(:poll_for_exit).and_raise(ChildProcess::TimeoutError)
|
31
|
+
allow(process).to receive(:send_kill).and_raise(Errno::ESRCH.new)
|
32
|
+
|
33
|
+
process.start
|
34
|
+
expect { process.stop }.not_to raise_error
|
35
|
+
|
36
|
+
allow(process).to receive(:alive?).and_return(false)
|
37
|
+
|
38
|
+
process.send(:send_signal, 'TERM')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe ChildProcess::Unix::IO do
|
43
|
+
let(:io) { ChildProcess::Unix::IO.new }
|
44
|
+
|
45
|
+
it "raises an ArgumentError if given IO does not respond to :to_io" do
|
46
|
+
expect { io.stdout = nil }.to raise_error(ArgumentError, /to respond to :to_io/)
|
47
|
+
end
|
48
|
+
|
49
|
+
it "raises a TypeError if #to_io does not return an IO" do
|
50
|
+
fake_io = Object.new
|
51
|
+
def fake_io.to_io() StringIO.new end
|
52
|
+
|
53
|
+
expect { io.stdout = fake_io }.to raise_error(TypeError, /expected IO, got/)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
data/spec/windows_spec.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
require File.expand_path('../spec_helper', __FILE__)
|
2
|
-
require "pid_behavior"
|
3
|
-
|
4
|
-
if ChildProcess.windows?
|
5
|
-
describe ChildProcess::Windows::Process do
|
6
|
-
it_behaves_like "a platform that provides the child's pid"
|
7
|
-
end
|
8
|
-
|
9
|
-
describe ChildProcess::Windows::IO do
|
10
|
-
let(:io) { ChildProcess::Windows::IO.new }
|
11
|
-
|
12
|
-
it "raises an ArgumentError if given IO does not respond to :fileno" do
|
13
|
-
expect { io.stdout = nil }.to raise_error(ArgumentError, /must have :fileno or :to_io/)
|
14
|
-
end
|
15
|
-
|
16
|
-
it "raises an ArgumentError if the #to_io does not return an IO " do
|
17
|
-
fake_io = Object.new
|
18
|
-
def fake_io.to_io() StringIO.new end
|
19
|
-
|
20
|
-
expect { io.stdout = fake_io }.to raise_error(ArgumentError, /must have :fileno or :to_io/)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
1
|
+
require File.expand_path('../spec_helper', __FILE__)
|
2
|
+
require "pid_behavior"
|
3
|
+
|
4
|
+
if ChildProcess.windows?
|
5
|
+
describe ChildProcess::Windows::Process do
|
6
|
+
it_behaves_like "a platform that provides the child's pid"
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ChildProcess::Windows::IO do
|
10
|
+
let(:io) { ChildProcess::Windows::IO.new }
|
11
|
+
|
12
|
+
it "raises an ArgumentError if given IO does not respond to :fileno" do
|
13
|
+
expect { io.stdout = nil }.to raise_error(ArgumentError, /must have :fileno or :to_io/)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "raises an ArgumentError if the #to_io does not return an IO " do
|
17
|
+
fake_io = Object.new
|
18
|
+
def fake_io.to_io() StringIO.new end
|
19
|
+
|
20
|
+
expect { io.stdout = fake_io }.to raise_error(ArgumentError, /must have :fileno or :to_io/)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: childprocess
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jari Bakken
|
8
8
|
- Eric Kessler
|
9
|
-
|
9
|
+
- Shane da Silva
|
10
|
+
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date:
|
13
|
+
date: 2021-06-09 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: rspec
|
@@ -39,20 +40,6 @@ dependencies:
|
|
39
40
|
- - "~>"
|
40
41
|
- !ruby/object:Gem::Version
|
41
42
|
version: '0.0'
|
42
|
-
- !ruby/object:Gem::Dependency
|
43
|
-
name: rake
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - "<"
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: '12.0'
|
49
|
-
type: :development
|
50
|
-
prerelease: false
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - "<"
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: '12.0'
|
56
43
|
- !ruby/object:Gem::Dependency
|
57
44
|
name: coveralls
|
58
45
|
requirement: !ruby/object:Gem::Requirement
|
@@ -71,9 +58,9 @@ description: This gem aims at being a simple and reliable solution for controlli
|
|
71
58
|
external programs running in the background on any Ruby / OS combination.
|
72
59
|
email:
|
73
60
|
- morrow748@gmail.com
|
61
|
+
- shane@dasilva.io
|
74
62
|
executables: []
|
75
|
-
extensions:
|
76
|
-
- ext/mkrf_conf.rb
|
63
|
+
extensions: []
|
77
64
|
extra_rdoc_files: []
|
78
65
|
files:
|
79
66
|
- ".document"
|
@@ -87,7 +74,6 @@ files:
|
|
87
74
|
- Rakefile
|
88
75
|
- appveyor.yml
|
89
76
|
- childprocess.gemspec
|
90
|
-
- ext/mkrf_conf.rb
|
91
77
|
- lib/childprocess.rb
|
92
78
|
- lib/childprocess/abstract_io.rb
|
93
79
|
- lib/childprocess/abstract_process.rb
|
@@ -101,6 +87,7 @@ files:
|
|
101
87
|
- lib/childprocess/unix/fork_exec_process.rb
|
102
88
|
- lib/childprocess/unix/io.rb
|
103
89
|
- lib/childprocess/unix/lib.rb
|
90
|
+
- lib/childprocess/unix/platform/arm64-macosx.rb
|
104
91
|
- lib/childprocess/unix/platform/i386-linux.rb
|
105
92
|
- lib/childprocess/unix/platform/i386-solaris.rb
|
106
93
|
- lib/childprocess/unix/platform/x86_64-linux.rb
|
@@ -125,11 +112,11 @@ files:
|
|
125
112
|
- spec/spec_helper.rb
|
126
113
|
- spec/unix_spec.rb
|
127
114
|
- spec/windows_spec.rb
|
128
|
-
homepage:
|
115
|
+
homepage: https://github.com/enkessler/childprocess
|
129
116
|
licenses:
|
130
117
|
- MIT
|
131
118
|
metadata: {}
|
132
|
-
post_install_message:
|
119
|
+
post_install_message:
|
133
120
|
rdoc_options: []
|
134
121
|
require_paths:
|
135
122
|
- lib
|
@@ -137,16 +124,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
124
|
requirements:
|
138
125
|
- - ">="
|
139
126
|
- !ruby/object:Gem::Version
|
140
|
-
version:
|
127
|
+
version: 2.4.0
|
141
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
129
|
requirements:
|
143
130
|
- - ">="
|
144
131
|
- !ruby/object:Gem::Version
|
145
132
|
version: '0'
|
146
133
|
requirements: []
|
147
|
-
|
148
|
-
|
149
|
-
signing_key:
|
134
|
+
rubygems_version: 3.1.4
|
135
|
+
signing_key:
|
150
136
|
specification_version: 4
|
151
137
|
summary: A simple and reliable solution for controlling external programs running
|
152
138
|
in the background on any Ruby / OS combination.
|
data/ext/mkrf_conf.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
# Based on the example from https://en.wikibooks.org/wiki/Ruby_Programming/RubyGems#How_to_install_different_versions_of_gems_depending_on_which_version_of_ruby_the_installee_is_using
|
2
|
-
require 'rubygems'
|
3
|
-
require 'rubygems/command.rb'
|
4
|
-
require 'rubygems/dependency_installer.rb'
|
5
|
-
|
6
|
-
begin
|
7
|
-
Gem::Command.build_args = ARGV
|
8
|
-
rescue NoMethodError # rubocop:disable Lint/HandleExceptions
|
9
|
-
end
|
10
|
-
|
11
|
-
inst = Gem::DependencyInstaller.new
|
12
|
-
|
13
|
-
begin
|
14
|
-
if Gem.win_platform?
|
15
|
-
inst.install 'ffi', Gem::Requirement.new('~> 1.0', '>= 1.0.11')
|
16
|
-
end
|
17
|
-
rescue # rubocop:disable Lint/RescueWithoutErrorClass
|
18
|
-
exit(1)
|
19
|
-
end
|
20
|
-
|
21
|
-
# create dummy rakefile to indicate success
|
22
|
-
File.open(File.join(File.dirname(__FILE__), 'Rakefile'), 'w') do |f|
|
23
|
-
f.write("task :default\n")
|
24
|
-
end
|