Skip to content

Commit

Permalink
Merge pull request #247 from dafyddcrosby/win_exec_time
Browse files Browse the repository at this point in the history
[#239] Add execution time to Windows shellout object
  • Loading branch information
tpowell-progress authored Jun 18, 2024
2 parents e8d61e3 + dd2ff71 commit 48ba6e7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/mixlib/shellout/windows.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def run_command
stderr_read, stderr_write = IO.pipe
stdin_read, stdin_write = IO.pipe
open_streams = [ stdout_read, stderr_read ]
@execution_time = 0

begin

Expand Down Expand Up @@ -105,6 +106,8 @@ def run_command
wait_status = WaitForSingleObject(process.process_handle, 0)
case wait_status
when WAIT_OBJECT_0
# Save the execution time
@execution_time = Time.now - start_wait
# Get process exit code
exit_code = [0].pack("l")
unless GetExitCodeProcess(process.process_handle, exit_code)
Expand All @@ -127,6 +130,9 @@ def run_command
logger&.warn("Failed to kill timed out process #{process.process_id}")
end

# Save the execution time
@execution_time = Time.now - start_wait

raise Mixlib::ShellOut::CommandTimeout, [
"command timed out:",
format_for_exception,
Expand Down

0 comments on commit 48ba6e7

Please sign in to comment.