Project

General

Profile

Actions

Feature #8083

open

Exit status is limited to one-byte values which is invalid for Windows

Added by rutsky (Vladimir Rutsky) over 8 years ago. Updated over 8 years ago.

Status:
Assigned
Priority:
Normal
Assignee:
cruby-windows
Target version:
-
[ruby-core:53368]

Description

=begin
Windows uses 32-bit process exit codes so Ruby incorrectly truncates them to one byte:

C:\Ruby193\bin>ruby -e "system('C:\windows\system32\cmd.exe /c exit 255'); puts $?.exitstatus"
255

C:\Ruby193\bin>ruby -e "system('C:\windows\system32\cmd.exe /c exit 256'); puts $?.exitstatus"
0

C:\Ruby193\bin>ruby -e "system('C:\windows\system32\cmd.exe /c exit 257'); puts $?.exitstatus"
1

Similar code works correctly in Python:

C:\Python27>python -c "import subprocess; print subprocess.call('C:\windows\system32\cmd.exe /c exit 255')"
255

C:\Python27>python -c "import subprocess; print subprocess.call('C:\windows\system32\cmd.exe /c exit 256')"
256

C:\Python27>python -c "import subprocess; print subprocess.call('C:\windows\system32\cmd.exe /c exit 257')"
257
=end

Actions

Also available in: Atom PDF