mixlib-shellout 2.2.2-universal-mingw32 → 2.2.3-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cadbef0918a7fec08ca405f56a5cd329f54660ca
4
- data.tar.gz: baf26f7055af2c88854e9ea08f903cba4b433181
3
+ metadata.gz: 0fe50b48e3831e8cee3693baca5b59de3365f7d6
4
+ data.tar.gz: b9fbbf0761c40d333de217178f8bcc54a3722cbe
5
5
  SHA512:
6
- metadata.gz: b0b1948708503dd9d9d78eaee8ef82482a13460f6f4af30dd533fa861c6e3d8af0f387df7e70d3eb7eeab3f6eda81121aac7c2bf0c9b0695b0a1a71d53be820b
7
- data.tar.gz: aaf5ba1761ff3fe90afbd6f2b40fae823fff038dded0648b36269c7225f140355b15eb7cc72235d047879e156e72ab32225182af7e9881f127d54a7435c17a9c
6
+ metadata.gz: 6c8618cf2e31b4215aac4278fd6a793d9c38aa40edbf6291dbf3c4e4bac3f20afa9d39f29640427207f958c2e7d82cb7016dc5b0469c6a923178d3dbf3eaea50
7
+ data.tar.gz: 6242df9234b5dda6a68a89dfed789244b3b0e3d362801ca419d07c361b56497246d5a0b382b7f06136688d00ce20ad3ce0ffef8714779a362108604b6344ba22
@@ -1,5 +1,5 @@
1
1
  module Mixlib
2
2
  class ShellOut
3
- VERSION = "2.2.2"
3
+ VERSION = "2.2.3"
4
4
  end
5
5
  end
@@ -43,7 +43,6 @@ module Mixlib
43
43
  # Missing lots of features from the UNIX version, such as
44
44
  # uid, etc.
45
45
  def run_command
46
-
47
46
  #
48
47
  # Create pipes to capture stdout and stderr,
49
48
  #
@@ -79,6 +78,7 @@ module Mixlib
79
78
  # Start the process
80
79
  #
81
80
  process = Process.create(create_process_args)
81
+ logger.debug(Utils.format_process(process, app_name, command_line, timeout)) if logger
82
82
  begin
83
83
  # Start pushing data into input
84
84
  stdin_write << input if input
@@ -107,12 +107,19 @@ module Mixlib
107
107
  # Kill the process
108
108
  if (Time.now - start_wait) > timeout
109
109
  begin
110
+ require 'wmi-lite/wmi'
111
+ wmi = WmiLite::Wmi.new
112
+ Utils.kill_process_tree(process.process_id, wmi, logger)
110
113
  Process.kill(:KILL, process.process_id)
111
- rescue Errno::EIO
114
+ rescue Errno::EIO, SystemCallError
112
115
  logger.warn("Failed to kill timed out process #{process.process_id}") if logger
113
116
  end
114
117
 
115
- raise Mixlib::ShellOut::CommandTimeout, "command timed out:\n#{format_for_exception}"
118
+ raise Mixlib::ShellOut::CommandTimeout, [
119
+ "command timed out:",
120
+ format_for_exception,
121
+ Utils.format_process(process, app_name, command_line, timeout)
122
+ ].join("\n")
116
123
  end
117
124
 
118
125
  consume_output(open_streams, stdout_read, stderr_read)
@@ -313,6 +320,42 @@ module Mixlib
313
320
  def self.executable?(path)
314
321
  File.executable?(path) && !File.directory?(path)
315
322
  end
323
+
324
+ # recursively kills all child processes of given pid
325
+ # calls itself querying for children child procs until
326
+ # none remain. Important that a single WmiLite instance
327
+ # is passed in since each creates its own WMI rpc process
328
+ def self.kill_process_tree(pid, wmi, logger)
329
+ wmi.query("select * from Win32_Process where ParentProcessID=#{pid}").each do |instance|
330
+ child_pid = instance.wmi_ole_object.processid
331
+ kill_process_tree(child_pid, wmi, logger)
332
+ begin
333
+ logger.debug([
334
+ "killing child process #{child_pid}::",
335
+ "#{instance.wmi_ole_object.Name} of parent #{pid}"
336
+ ].join) if logger
337
+ kill_process(instance)
338
+ rescue Errno::EIO, SystemCallError
339
+ logger.debug([
340
+ "Failed to kill child process #{child_pid}::",
341
+ "#{instance.wmi_ole_object.Name} of parent #{pid}"
342
+ ].join) if logger
343
+ end
344
+ end
345
+ end
346
+
347
+ def self.kill_process(instance)
348
+ Process.kill(:KILL, instance.wmi_ole_object.processid)
349
+ end
350
+
351
+ def self.format_process(process, app_name, command_line, timeout)
352
+ msg = []
353
+ msg << "ProcessId: #{process.process_id}"
354
+ msg << "app_name: #{app_name}"
355
+ msg << "command_line: #{command_line}"
356
+ msg << "timeout: #{timeout}"
357
+ msg.join("\n")
358
+ end
316
359
  end
317
360
  end # class
318
361
  end
@@ -3,5 +3,6 @@ gemspec = eval(File.read(File.expand_path("../mixlib-shellout.gemspec", __FILE__
3
3
  gemspec.platform = Gem::Platform.new(["universal", "mingw32"])
4
4
 
5
5
  gemspec.add_dependency "win32-process", "~> 0.8.2"
6
+ gemspec.add_dependency "wmi-lite", "~> 1.0"
6
7
 
7
8
  gemspec
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixlib-shellout
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.2
4
+ version: 2.2.3
5
5
  platform: universal-mingw32
6
6
  authors:
7
7
  - Opscode
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-19 00:00:00.000000000 Z
11
+ date: 2015-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 0.8.2
41
+ - !ruby/object:Gem::Dependency
42
+ name: wmi-lite
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
41
55
  description: Run external commands on Unix or Windows
42
56
  email: info@opscode.com
43
57
  executables: []
@@ -77,8 +91,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
91
  version: '0'
78
92
  requirements: []
79
93
  rubyforge_project:
80
- rubygems_version: 2.4.6
94
+ rubygems_version: 2.4.8
81
95
  signing_key:
82
96
  specification_version: 4
83
97
  summary: Run external commands on Unix or Windows
84
98
  test_files: []
99
+ has_rdoc: