shexecutor 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/shexecutor/version.rb +1 -1
- data/lib/shexecutor.rb +26 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5a90086a0b0551fc5c8296e15e8261a6c05103e
|
4
|
+
data.tar.gz: b471206bf6fe04e173ca72e5690eace7e922233f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7eaf4861a28bac3294e80ab2745261693f3cadba1f84b07ed78337c4c325f728ea0c94196d99725b857c3d9debbdc31fe5c89cc569bb798642863331c05fb73
|
7
|
+
data.tar.gz: e62998f6d86fb8ae0200cf880b7c4dc29e6a3dc4ee62dc4147e4cae09709e1b68f0c2a318dd268ea4b290e42b7a803e1f042107c94e491358afcd39696ed7489
|
data/Gemfile.lock
CHANGED
data/lib/shexecutor/version.rb
CHANGED
data/lib/shexecutor.rb
CHANGED
@@ -162,11 +162,15 @@ module SHExecutor
|
|
162
162
|
t1 = Thread.new do
|
163
163
|
begin
|
164
164
|
IO.copy_stream(stdout, data_out)
|
165
|
+
rescue Exception => ex
|
166
|
+
raise TimeoutError.new("execution expired") if @timeout_error
|
165
167
|
end
|
166
168
|
end
|
167
169
|
t2 = Thread.new do
|
168
170
|
begin
|
169
171
|
IO.copy_stream(stderr, data_err)
|
172
|
+
rescue Exception => ex
|
173
|
+
raise TimeoutError.new("execution expired") if @timeout_error
|
170
174
|
end
|
171
175
|
end
|
172
176
|
m = Mutex.new
|
@@ -174,6 +178,7 @@ module SHExecutor
|
|
174
178
|
# track timeout if required. Do this ourselves since the mechanism
|
175
179
|
# is simple and Timeout struggles from multi-threading issues.
|
176
180
|
# IO.copy_stream stop the Timeout exception from being thrown properly.
|
181
|
+
timedout = false
|
177
182
|
t3 = Thread.new do
|
178
183
|
count = 0
|
179
184
|
while (count < @options[:timeout]*10) and (@t0.alive?) do
|
@@ -181,11 +186,15 @@ module SHExecutor
|
|
181
186
|
count = count + 1
|
182
187
|
end
|
183
188
|
m.synchronize do
|
189
|
+
if count >= @options[:timeout]*10
|
190
|
+
timedout = true
|
191
|
+
end
|
184
192
|
done = true
|
185
|
-
raise Timeout::Error.new("execution expired") if @t0.alive?
|
186
193
|
end
|
187
194
|
end if should_timeout?
|
188
195
|
stdin.close
|
196
|
+
t1.abort_on_exception = true if should_timeout?
|
197
|
+
t2.abort_on_exception = true if should_timeout?
|
189
198
|
t3.abort_on_exception = true if should_timeout?
|
190
199
|
t1.join if not should_timeout?
|
191
200
|
t2.join if not should_timeout?
|
@@ -200,9 +209,14 @@ module SHExecutor
|
|
200
209
|
d = done
|
201
210
|
end
|
202
211
|
end
|
203
|
-
|
204
|
-
|
205
|
-
|
212
|
+
|
213
|
+
if not timedout
|
214
|
+
t1.join
|
215
|
+
t2.join
|
216
|
+
t3.join
|
217
|
+
else
|
218
|
+
@timeout_error = true
|
219
|
+
end
|
206
220
|
end
|
207
221
|
end
|
208
222
|
return data_out, data_err, @t0
|
@@ -219,6 +233,7 @@ module SHExecutor
|
|
219
233
|
validate
|
220
234
|
begin
|
221
235
|
@data_out, @data_err, @result = run_process(@options[:application_path], *@options[:params])
|
236
|
+
raise Timeout::Error.new("execution expired") if @timeout_error
|
222
237
|
@result.join
|
223
238
|
@result.value
|
224
239
|
rescue Timeout::Error => ex
|
@@ -236,6 +251,13 @@ module SHExecutor
|
|
236
251
|
end
|
237
252
|
end
|
238
253
|
|
254
|
+
def kill_9_process(pid)
|
255
|
+
return if pid.nil?
|
256
|
+
Process.kill(9, pid)
|
257
|
+
rescue Errno::ESRCH
|
258
|
+
#done
|
259
|
+
end
|
260
|
+
|
239
261
|
def kill_process(pid)
|
240
262
|
return if pid.nil?
|
241
263
|
Process.kill("TERM", pid)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shexecutor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ernst van Graan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|