dev_commands 0.0.41 → 0.0.42
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/array.rb +1 -6
- data/lib/build.rb +23 -17
- data/lib/command.rb +31 -39
- data/lib/hash.rb +2 -2
- data/spec/command_spec.rb +6 -37
- metadata +23 -80
- data/lib/timeout.rb +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b611814d3d0fd7323179bf1a3f0280d60a13099
|
4
|
+
data.tar.gz: 949e91336bd6fb6481716f8c1d6fa490d10162d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0da1876adb0693a5d7cf0ac17bfa5c3a107fdba5e4d360cf53fb87beb0698cefaf295fd77e2852e27b16cbe583909e87888b2dd80c8d860b7ff6dcd684109a1
|
7
|
+
data.tar.gz: 13e503c95cad72a4648ee7fba49596e6265b3af3fefa01fcbb98c1e2e97f9b65ca3392de8bdb9e85c5d9481a20536cafa8293c3827d1165c9a62eb90270e6ff2
|
data/lib/array.rb
CHANGED
@@ -1,14 +1,9 @@
|
|
1
1
|
class Array
|
2
|
-
def execute
|
2
|
+
def execute
|
3
3
|
i=0
|
4
4
|
while i < self.length
|
5
5
|
self[i]=Command.new(self[i]) if(self[i].is_a?(String))
|
6
6
|
self[i]=Command.new(self[i]) if(self[i].is_a?(Hash) && !self[i].is_a?(Command))
|
7
|
-
|
8
|
-
if(!value.nil? && value.is_a?(Hash))
|
9
|
-
value.each{|k,v|self[i][k]=v}
|
10
|
-
end
|
11
|
-
|
12
7
|
self[i].execute if(self[i].is_a?(Command))
|
13
8
|
i=i+1
|
14
9
|
end
|
data/lib/build.rb
CHANGED
@@ -1,22 +1,28 @@
|
|
1
1
|
require_relative('msbuild.rb')
|
2
|
-
|
2
|
+
require_relative('gemspec.rb')
|
3
3
|
class Build < Array
|
4
4
|
def update
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
5
|
+
|
6
|
+
changed = true
|
7
|
+
changed = Git.has_changes? if(File.exists?('.git') && defined?(Git))
|
8
|
+
changed = Svn.has_changes? if(File.exists?('.svn') && defined?(Svn))
|
9
|
+
if(changed)
|
10
|
+
Dir.glob('*.gemspec'){|gemspec|
|
11
|
+
add "gem build #{gemspec}" if !File.exist?(Gemspec.gemfile gemspec)
|
12
|
+
}
|
13
|
+
Dir.glob('*.sln'){|sln_file|
|
14
|
+
vs_version=MSBuild.get_vs_version(sln_file)
|
15
|
+
if(MSBuild.has_version?(vs_version))
|
16
|
+
MSBuild.get_configurations(sln_file).each{ |configuration|
|
17
|
+
MSBuild.get_platforms(sln_file).each{|platform|
|
18
|
+
#Console.debug "configuration='#{configuration}', platform='#{platform}'"
|
19
|
+
self.add "\"#{MSBuild.get_version(vs_version)}\" \"#{sln_file}\" /nologo /p:Configuration=#{configuration} /p:Platform=\"#{platform}\""
|
20
|
+
}
|
21
|
+
}
|
22
|
+
else
|
23
|
+
"puts version #{vs_version} not found for MsBuild"
|
24
|
+
end
|
25
|
+
}
|
26
|
+
end
|
21
27
|
end
|
22
28
|
end
|
data/lib/command.rb
CHANGED
@@ -3,9 +3,26 @@ require_relative('./array.rb')
|
|
3
3
|
require_relative('./hash.rb')
|
4
4
|
require_relative('./timer.rb')
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
# = Command
|
7
|
+
#
|
8
|
+
# execution of system commands
|
9
|
+
#
|
10
|
+
# = Keys
|
11
|
+
#
|
12
|
+
# - :input The input of the commands.
|
13
|
+
# - :timeout The timeout in seconds.
|
14
|
+
# a value of zero is to infinite timeout.
|
15
|
+
# defaults to zero
|
16
|
+
# - :directory The working directory for the command.
|
17
|
+
# defaults to the current directory
|
18
|
+
# - :exit_code The exit code of the command
|
19
|
+
# - :output The output contains the stdout output of the command
|
20
|
+
# - :error The error contains stderr output of the command
|
21
|
+
# - :machine The name of the machine the command executed on
|
22
|
+
# - :user The user name
|
23
|
+
# - :start_time
|
24
|
+
# - :end_time
|
25
|
+
#
|
9
26
|
class Command < Hash
|
10
27
|
def initialize command
|
11
28
|
|
@@ -31,23 +48,12 @@ class Command < Hash
|
|
31
48
|
end
|
32
49
|
end
|
33
50
|
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
def execute value=nil
|
39
|
-
|
40
|
-
if(!value.nil? && value.is_a?(Hash))
|
41
|
-
value.each{|k,v|self[k]=v}
|
42
|
-
end
|
51
|
+
def execute
|
52
|
+
puts "#{self[:input]}" if(!self.has_key?(:quiet) || !self[:quiet])
|
43
53
|
pwd=Dir.pwd
|
44
54
|
Dir.chdir(self[:directory]) if(self.has_key?(:directory) && File.exists?(self[:directory]))
|
45
55
|
self[:directory] = pwd if(self[:directory].length==0)
|
46
|
-
|
47
|
-
puts "#{self[:input]} (#{self[:directory]}) timeout #{self[:timeout].to_s}" if(!quiet?)
|
48
|
-
else
|
49
|
-
puts "#{self[:input]} (#{self[:directory]})" if(!quiet?)
|
50
|
-
end
|
56
|
+
|
51
57
|
self[:machine] = Command.machine
|
52
58
|
self[:user] = Command.user
|
53
59
|
|
@@ -67,27 +73,10 @@ class Command < Hash
|
|
67
73
|
self[:end_time] = Time.now
|
68
74
|
else
|
69
75
|
begin
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
self[:end_time] = Time.now
|
75
|
-
else
|
76
|
-
require_relative 'timeout.rb'
|
77
|
-
#puts run_with_timeout(self[:input], self[:timeout], 1).to_s
|
78
|
-
#self[:output] = run_with_timeout(self[:input], self[:timeout], 1)
|
79
|
-
result=run_with_timeout(self[:input], self[:timeout], 1)
|
80
|
-
self[:output]=result[0]
|
81
|
-
self[:exit_code]=result[1]
|
82
|
-
|
83
|
-
self[:elapsed] = timer.elapsed_str
|
84
|
-
self[:end_time] = Time.now
|
85
|
-
|
86
|
-
if(timer.elapsed >= self[:timeout])
|
87
|
-
self[:exit_code]=1
|
88
|
-
self[:error] = self[:error] + "timed out"
|
89
|
-
end
|
90
|
-
end
|
76
|
+
self[:output],self[:error],status= Open3.capture3(self[:input])
|
77
|
+
self[:exit_code]=status.to_i
|
78
|
+
self[:elapsed] = timer.elapsed_str
|
79
|
+
self[:end_time] = Time.now
|
91
80
|
rescue Exception => e
|
92
81
|
self[:elapsed] = timer.elapsed_str
|
93
82
|
self[:end_time] = Time.now
|
@@ -99,10 +88,13 @@ class Command < Hash
|
|
99
88
|
Dir.chdir(pwd) if pwd != Dir.pwd
|
100
89
|
|
101
90
|
if(self[:exit_code] != 0)
|
102
|
-
if(!quiet
|
91
|
+
if(!self.has_key?(:quiet) || !self[:quiet])
|
92
|
+
puts ' '
|
103
93
|
puts "exit_code=#{self[:exit_code]}"
|
94
|
+
puts ' '
|
104
95
|
puts self[:output]
|
105
96
|
puts self[:error]
|
97
|
+
puts ' '
|
106
98
|
end
|
107
99
|
if(!self.has_key?(:ignore_failure) || !self[:ignore_failure])
|
108
100
|
raise "#{self[:input]} failed"
|
data/lib/hash.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Hash
|
2
|
-
def execute
|
2
|
+
def execute
|
3
3
|
self.each{|k,v|
|
4
4
|
v.update if v.respond_to?(:update)
|
5
5
|
if(v.is_a?(Array) && v.length==0)
|
@@ -7,7 +7,7 @@ class Hash
|
|
7
7
|
else
|
8
8
|
#puts "executing #{k}"
|
9
9
|
|
10
|
-
v.execute
|
10
|
+
v.execute if v.respond_to?(:execute)
|
11
11
|
end
|
12
12
|
}
|
13
13
|
end
|
data/spec/command_spec.rb
CHANGED
@@ -4,7 +4,7 @@ require 'fileutils'
|
|
4
4
|
|
5
5
|
describe Command do
|
6
6
|
it "should be able to execute ruby --version command" do
|
7
|
-
cmd=Command.new(
|
7
|
+
cmd=Command.new("ruby --version")
|
8
8
|
# Timeout
|
9
9
|
expect(cmd[:timeout]).to eq(0)
|
10
10
|
cmd[:timeout]=3000
|
@@ -58,7 +58,7 @@ describe Command do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should be able to write to/load from JSON" do
|
61
|
-
cmd=Command.new(
|
61
|
+
cmd=Command.new("ruby --version")
|
62
62
|
expect(cmd[:timeout]).to eq(0)
|
63
63
|
expect(cmd[:input]).to eq("ruby --version")
|
64
64
|
cmd2=Command.new(JSON.parse(cmd.to_json))
|
@@ -66,12 +66,6 @@ describe Command do
|
|
66
66
|
expect(cmd2[:input]).to eq("ruby --version")
|
67
67
|
end
|
68
68
|
|
69
|
-
it "should be able to timeout" do
|
70
|
-
cmd=Command.new({ :input => 'ftp', :timeout => 0.5, :ignore_failure => true, :quiet => true})
|
71
|
-
cmd.execute
|
72
|
-
expect(cmd[:exit_code]).not_to eq(0)
|
73
|
-
end
|
74
|
-
|
75
69
|
it "should be able to execute rake command in specific directory" do
|
76
70
|
dir="#{File.dirname(__FILE__)}/tmp/rake_test"
|
77
71
|
FileUtils.mkdir_p(dir) if(!File.exists?(dir))
|
@@ -80,41 +74,16 @@ describe Command do
|
|
80
74
|
f.puts " puts 'rake_test'"
|
81
75
|
f.puts "end"
|
82
76
|
}
|
83
|
-
cmd=Command.new(
|
77
|
+
cmd=Command.new("rake")
|
84
78
|
cmd[:directory]=dir
|
85
79
|
cmd.execute
|
86
80
|
FileUtils.rm_r("#{File.dirname(__FILE__)}/tmp")
|
87
81
|
expect(cmd[:output].include?('rake_test')).to eq(true)
|
88
82
|
end
|
89
83
|
|
90
|
-
it "should fail when calling rake produces an error" do
|
91
|
-
dir="#{File.dirname(__FILE__)}/tmp/rake_error_test"
|
92
|
-
FileUtils.mkdir_p(dir) if(!File.exists?(dir))
|
93
|
-
File.open("#{dir}/rakefile.rb","w") { |f|
|
94
|
-
f.puts "task :default do"
|
95
|
-
f.puts " raise 'rake_test'"
|
96
|
-
f.puts "end"
|
97
|
-
}
|
98
|
-
cmd=Command.new({ :input => 'rake', :ignore_failure => true, :quiet => true})
|
99
|
-
cmd[:directory]=dir
|
100
|
-
cmd.execute({:quiet => true})
|
101
|
-
FileUtils.rm_r("#{File.dirname(__FILE__)}/tmp")
|
102
|
-
expect(cmd[:exit_code]).not_to eq(0)
|
103
|
-
|
104
|
-
cmd=Command.new({ :input => 'rake bogus', :ignore_failure => true, :quiet => true})
|
105
|
-
cmd[:directory]=dir
|
106
|
-
cmd.execute
|
107
|
-
expect(cmd[:exit_code]).not_to eq(0)
|
108
|
-
|
109
|
-
cmd=Command.new({ :input => 'rake bogus', :timeout => 3, :ignore_failure => true, :quiet => true})
|
110
|
-
cmd[:directory]=dir
|
111
|
-
cmd.execute
|
112
|
-
expect(cmd[:exit_code]).not_to eq(0)
|
113
|
-
end
|
114
|
-
|
115
84
|
it "should be able to execute an array of commands" do
|
116
85
|
help=['git --help','rake --help','ruby --help']
|
117
|
-
help.execute
|
86
|
+
help.execute
|
118
87
|
File.open('help.html','w'){|f|f.write(help.to_html)}
|
119
88
|
end
|
120
89
|
|
@@ -122,11 +91,11 @@ describe Command do
|
|
122
91
|
commands=Hash.new
|
123
92
|
commands[:help]=['git --help','rake --help','ruby --help']
|
124
93
|
commands[:version]=['git --version','rake --version','ruby --version']
|
125
|
-
commands.execute
|
94
|
+
commands.execute
|
126
95
|
File.open('commands.html','w'){|f|f.write(commands.to_html)}
|
127
96
|
end
|
128
97
|
|
129
|
-
it "
|
98
|
+
it "hsould be able to get the output" do
|
130
99
|
expect(Command.output('git --version').include?('git version')).to eq(true)
|
131
100
|
expect(Command.output('bogus --version').include?('bogus version')).to eq(false)
|
132
101
|
end
|
metadata
CHANGED
@@ -1,133 +1,79 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dev_commands
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.42
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lou Parslow
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-01-
|
11
|
+
date: 2015-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '10.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
26
|
+
version: '10.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - '>='
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: yard
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - '>='
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: bundler
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - '>='
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - '>='
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rake
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - '>='
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - '>='
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rspec
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - '>='
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
33
|
+
version: '3.0'
|
90
34
|
type: :development
|
91
35
|
prerelease: false
|
92
36
|
version_requirements: !ruby/object:Gem::Requirement
|
93
37
|
requirements:
|
94
|
-
- -
|
38
|
+
- - "~>"
|
95
39
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
40
|
+
version: '3.0'
|
97
41
|
- !ruby/object:Gem::Dependency
|
98
42
|
name: yard
|
99
43
|
requirement: !ruby/object:Gem::Requirement
|
100
44
|
requirements:
|
101
|
-
- -
|
45
|
+
- - "~>"
|
102
46
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
47
|
+
version: '0.8'
|
104
48
|
type: :development
|
105
49
|
prerelease: false
|
106
50
|
version_requirements: !ruby/object:Gem::Requirement
|
107
51
|
requirements:
|
108
|
-
- -
|
52
|
+
- - "~>"
|
109
53
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
54
|
+
version: '0.8'
|
111
55
|
- !ruby/object:Gem::Dependency
|
112
56
|
name: bundler
|
113
57
|
requirement: !ruby/object:Gem::Requirement
|
114
58
|
requirements:
|
115
|
-
- -
|
59
|
+
- - "~>"
|
116
60
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
61
|
+
version: '1.7'
|
118
62
|
type: :development
|
119
63
|
prerelease: false
|
120
64
|
version_requirements: !ruby/object:Gem::Requirement
|
121
65
|
requirements:
|
122
|
-
- -
|
66
|
+
- - "~>"
|
123
67
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
68
|
+
version: '1.7'
|
125
69
|
description: execution of system commands
|
126
70
|
email: lou.parslow@gmail.com
|
127
71
|
executables: []
|
128
72
|
extensions: []
|
129
73
|
extra_rdoc_files: []
|
130
74
|
files:
|
75
|
+
- LICENSE
|
76
|
+
- README.md
|
131
77
|
- lib/add.rb
|
132
78
|
- lib/analyze.rb
|
133
79
|
- lib/array.rb
|
@@ -151,7 +97,6 @@ files:
|
|
151
97
|
- lib/setup.rb
|
152
98
|
- lib/test.rb
|
153
99
|
- lib/text.rb
|
154
|
-
- lib/timeout.rb
|
155
100
|
- lib/timer.rb
|
156
101
|
- lib/update.rb
|
157
102
|
- lib/upgrade.rb
|
@@ -162,8 +107,6 @@ files:
|
|
162
107
|
- spec/sln-vs12-example/rakefile.rb
|
163
108
|
- spec/sln-vs9-example/rakefile.rb
|
164
109
|
- spec/text_spec.rb
|
165
|
-
- LICENSE
|
166
|
-
- README.md
|
167
110
|
homepage: http://github.com/lou-parslow/dev_commands.gem
|
168
111
|
licenses:
|
169
112
|
- Apache 2.0
|
@@ -174,17 +117,17 @@ require_paths:
|
|
174
117
|
- lib
|
175
118
|
required_ruby_version: !ruby/object:Gem::Requirement
|
176
119
|
requirements:
|
177
|
-
- -
|
120
|
+
- - ">="
|
178
121
|
- !ruby/object:Gem::Version
|
179
122
|
version: '0'
|
180
123
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
124
|
requirements:
|
182
|
-
- -
|
125
|
+
- - ">="
|
183
126
|
- !ruby/object:Gem::Version
|
184
127
|
version: '0'
|
185
128
|
requirements: []
|
186
129
|
rubyforge_project:
|
187
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.2.2
|
188
131
|
signing_key:
|
189
132
|
specification_version: 4
|
190
133
|
summary: gem to execute system commands
|
data/lib/timeout.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
############################################################################
|
2
|
-
# The following code is based on code originally copied from
|
3
|
-
# https://gist.github.com/lpar/1032297
|
4
|
-
# Gist title: lpar/timeout.rb
|
5
|
-
############################################################################
|
6
|
-
# Runs a specified shell command in a separate thread.
|
7
|
-
# If it exceeds the given timeout in seconds, kills it.
|
8
|
-
# Returns any output produced by the command (stdout or stderr) as a String.
|
9
|
-
# Uses Kernel.select to wait up to the tick length (in seconds) between
|
10
|
-
# checks on the command's status
|
11
|
-
#
|
12
|
-
# If you've got a cleaner way of doing this, I'd be interested to see it.
|
13
|
-
# If you think you can do it with Ruby's Timeout module, think again.
|
14
|
-
def run_with_timeout(command, timeout, tick)
|
15
|
-
output = ''
|
16
|
-
exit_code=1
|
17
|
-
begin
|
18
|
-
# Start task in another thread, which spawns a process
|
19
|
-
stdin, stderrout, thread = Open3.popen2e(command)
|
20
|
-
# Get the pid of the spawned process
|
21
|
-
pid = thread[:pid]
|
22
|
-
start = Time.now
|
23
|
-
|
24
|
-
while (Time.now - start) < timeout and thread.alive?
|
25
|
-
# Wait up to `tick` seconds for output/error data
|
26
|
-
Kernel.select([stderrout], nil, nil, tick)
|
27
|
-
# Try to read the data
|
28
|
-
begin
|
29
|
-
output << stderrout.read_nonblock(BUFFER_SIZE)
|
30
|
-
rescue IO::WaitReadable
|
31
|
-
# A read would block, so loop around for another select
|
32
|
-
rescue EOFError
|
33
|
-
# Command has completed, not really an error...
|
34
|
-
break
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
# Give Ruby time to clean up the other thread
|
39
|
-
sleep 1
|
40
|
-
|
41
|
-
if thread.alive?
|
42
|
-
# We need to kill the process, because killing the thread leaves
|
43
|
-
# the process alive but detached, annoyingly enough.
|
44
|
-
Process.kill("TERM", pid)
|
45
|
-
else
|
46
|
-
exit_code=thread.value
|
47
|
-
end
|
48
|
-
|
49
|
-
ensure
|
50
|
-
stdin.close if stdin
|
51
|
-
stderrout.close if stderrout
|
52
|
-
end
|
53
|
-
return [output,exit_code]
|
54
|
-
end
|