From e394f6b1609a195dd23932714d70d583f2e32177 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Tue, 18 Jun 2024 12:03:13 -0700 Subject: [PATCH 1/3] Add execution time to Windows shellout object Signed-off-by: Gilbert Sanchez Signed-off-by: David Crosby --- lib/mixlib/shellout/windows.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/mixlib/shellout/windows.rb b/lib/mixlib/shellout/windows.rb index 4c686676..8eae9d71 100644 --- a/lib/mixlib/shellout/windows.rb +++ b/lib/mixlib/shellout/windows.rb @@ -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 @@ -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) From e8895a1ae26dcfbd92988f383c0f78f2d905ff25 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Tue, 18 Jun 2024 12:03:17 -0700 Subject: [PATCH 2/3] Add same code to WAIT_TIMEOUT block Signed-off-by: Gilbert Sanchez Signed-off-by: David Crosby --- lib/mixlib/shellout/windows.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/mixlib/shellout/windows.rb b/lib/mixlib/shellout/windows.rb index 8eae9d71..99e8bb78 100644 --- a/lib/mixlib/shellout/windows.rb +++ b/lib/mixlib/shellout/windows.rb @@ -129,6 +129,9 @@ def run_command rescue SystemCallError 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:", From dd2ff716f2681a67dbb39979470d045c25bce584 Mon Sep 17 00:00:00 2001 From: Gilbert Sanchez Date: Tue, 18 Jun 2024 12:03:17 -0700 Subject: [PATCH 3/3] Remove trailing whitespace. Signed-off-by: Gilbert Sanchez Signed-off-by: David Crosby --- lib/mixlib/shellout/windows.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mixlib/shellout/windows.rb b/lib/mixlib/shellout/windows.rb index 99e8bb78..48c4d66f 100644 --- a/lib/mixlib/shellout/windows.rb +++ b/lib/mixlib/shellout/windows.rb @@ -129,7 +129,7 @@ def run_command rescue SystemCallError logger&.warn("Failed to kill timed out process #{process.process_id}") end - + # Save the execution time @execution_time = Time.now - start_wait