diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-01 21:17:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-02-01 21:17:05 +0300 |
commit | 143a33345cf3607ad35ec31130cec4922bc1113c (patch) | |
tree | 33b0a2658928f06d4ab20f8ec7d3aeadfbdd08d9 /lib/gitlab/popen.rb | |
parent | 3bdc719293f08ed357ef452f3e2a11a9b29531e7 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/gitlab/popen.rb')
-rw-r--r-- | lib/gitlab/popen.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/gitlab/popen.rb b/lib/gitlab/popen.rb index 7fa00d0c68c..586b271c4d0 100644 --- a/lib/gitlab/popen.rb +++ b/lib/gitlab/popen.rb @@ -10,10 +10,19 @@ module Gitlab Result = Struct.new(:cmd, :stdout, :stderr, :status, :duration) # Returns [stdout + stderr, status] + # status is either the exit code or the signal that killed the process def popen(cmd, path = nil, vars = {}, &block) result = popen_with_detail(cmd, path, vars, &block) - ["#{result.stdout}#{result.stderr}", result.status&.exitstatus] + # Process#waitpid returns Process::Status, which holds a 16-bit value. + # The higher-order 8 bits hold the exit() code (`exitstatus`). + # The lower-order bits holds whether the process was terminated. + # If the process didn't exit normally, `exitstatus` will be `nil`, + # but we still want a non-zero code, even if the value is + # platform-dependent. + status = result.status&.exitstatus || result.status.to_i + + ["#{result.stdout}#{result.stderr}", status] end # Returns Result |