Ruby Issue Tracking System: Issues
https://bugs.ruby-lang.org/
https://bugs.ruby-lang.org/favicon.ico?1711330511
2013-03-13T19:00:42Z
Ruby Issue Tracking System
Redmine
Ruby master - Feature #8083 (Assigned): Exit status is limited to one-byte values which is invali...
https://bugs.ruby-lang.org/issues/8083
2013-03-13T19:00:42Z
rutsky (Vladimir Rutsky)
rutsky.vladimir@gmail.com
<p>=begin<br>
Windows uses 32-bit process exit codes so Ruby incorrectly truncates them to one byte:</p>
<p>C:\Ruby193\bin>ruby -e "system('C:\windows\system32\cmd.exe /c exit 255'); puts $?.exitstatus"<br>
255</p>
<p>C:\Ruby193\bin>ruby -e "system('C:\windows\system32\cmd.exe /c exit 256'); puts $?.exitstatus"<br>
0</p>
<p>C:\Ruby193\bin>ruby -e "system('C:\windows\system32\cmd.exe /c exit 257'); puts $?.exitstatus"<br>
1</p>
<p>Similar code works correctly in Python:</p>
<p>C:\Python27>python -c "import subprocess; print subprocess.call('C:\windows\system32\cmd.exe /c exit 255')"<br>
255</p>
<p>C:\Python27>python -c "import subprocess; print subprocess.call('C:\windows\system32\cmd.exe /c exit 256')"<br>
256</p>
<p>C:\Python27>python -c "import subprocess; print subprocess.call('C:\windows\system32\cmd.exe /c exit 257')"<br>
257<br>
=end</p>