execute 0.1.47 → 0.1.49

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cmd.rb +4 -6
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b49fbcadb4a6069e7f09727a2ffe6d8576d41df3
4
- data.tar.gz: 64a9dcc69669e3b61a044ab1ad7d5937d54c94f8
3
+ metadata.gz: dc624c094f70bb09172061104c82f9eb5f55b2b1
4
+ data.tar.gz: 19033bbad9ef895c7811e160b43db5364843932f
5
5
  SHA512:
6
- metadata.gz: f6d33a8d7fec16f80c5a9c118df280216b2285ea3b64d55ee532fbf234ef03aa76b69ea50a7276bc7b53b910bbb81e9ed2de4a8d06df15941a8ed3a16adde840
7
- data.tar.gz: c3c6313b098eeb0879e18e8e74e6fda4924ce079e2f74354671064ed5ba61052c5a6140306b2154e7c7df66c0a2c8cd5811429ac0d29a9fc7c4a929431f8139a
6
+ metadata.gz: f0bc9754acfb8e057d81160ef94dbcd04fea93578d2ddadcaf095c808ca27f3f216d6aff9724747088979da31f79d861cdb8330ee3eec17a42340699004e5943
7
+ data.tar.gz: eaa8b84b6ce32f01498cc99e2cc5b6ec9135ad8fe10ce6bea38cd8f5b348cd96ffa64aec65fc71c65a2db1adadce0dd006da880a260c695df9268c7bf027b5ad
data/lib/cmd.rb CHANGED
@@ -84,7 +84,7 @@ class CMD < Hash
84
84
  sleep(0.1)
85
85
  if((Time.now - start_time).to_f > self[:timeout])
86
86
  self[:timed_out] = true
87
- interrupt
87
+ kill_child_processes
88
88
  sleep(0.1)
89
89
  end
90
90
  end
@@ -93,7 +93,7 @@ class CMD < Hash
93
93
 
94
94
  {:output => stdout,:error => stderr}.each do |key, stream|
95
95
  Thread.new do
96
- while wait_thr.alive? && !key?(:timed_out) do
96
+ while wait_thr.alive? && !key?(:timed_out) && !stream.closed? do
97
97
  if(!(char = stream.getc).nil?)
98
98
  case key
99
99
  when :output
@@ -116,14 +116,12 @@ class CMD < Hash
116
116
  self[:exit_code] = wait_thr.value.to_i
117
117
  end
118
118
  rescue Exception => e
119
- self[:error] = "#{self[:error]}\nException: #{e.to_s}"
120
- self[:exit_code]=1 unless(self[:exit_code].nil? || (self[:exit_code] == 0))
121
- rescue => e
119
+ kill_child_processes
122
120
  self[:error] = "#{self[:error]}\nException: #{e.to_s}"
123
121
  self[:exit_code]=1 unless(self[:exit_code].nil? || (self[:exit_code] == 0))
124
122
  end
125
123
  end
126
- def interrupt
124
+ def kill_child_processes
127
125
  process = get_child_processes(self[:pid])
128
126
  Sys::ProcTable.ps { |p| process << p if(p.pid == self[:pid]) }
129
127
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: execute
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.47
4
+ version: 0.1.49
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Marshall
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-22 00:00:00.000000000 Z
11
+ date: 2016-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler