https://redmine.ruby-lang.org/https://redmine.ruby-lang.org/favicon.ico?17113305112013-03-14T05:17:34ZRuby Issue Tracking SystemRuby master - Feature #8083: Exit status is limited to one-byte values which is invalid for Windowshttps://redmine.ruby-lang.org/issues/8083?journal_id=375812013-03-14T05:17:34Zluislavena (Luis Lavena)luislavena@gmail.com
<ul><li><strong>Status</strong> changed from <i>Open</i> to <i>Feedback</i></li></ul><p>Can you provide links to MSDN article that states this? (32-bits exit codes)</p>
<p>Thank you.</p> Ruby master - Feature #8083: Exit status is limited to one-byte values which is invalid for Windowshttps://redmine.ruby-lang.org/issues/8083?journal_id=375892013-03-14T14:44:50Zphasis68 (Heesob Park)phasis@gmail.com
<ul></ul><p>According to the document <a href="http://en.wikipedia.org/wiki/Exit_status#Windows" class="external">http://en.wikipedia.org/wiki/Exit_status#Windows</a>,<br>
"Windows uses 32-bit signed integers as exit codes. If a process fails initialization, a Windows system error code may be returned. Windows system error codes are available online.<br>
Exit codes are directly referenced, for example, by the command line interpreter CMD.exe in the errorlevel terminology inherited from DOS. .NET Framework processes and the Windows PowerShell refer to it as the ExitCode property of the Process object."</p>
<p>Refer to<br>
<a href="http://stackoverflow.com/questions/179565/exitcodes-bigger-than-255-possible" class="external">http://stackoverflow.com/questions/179565/exitcodes-bigger-than-255-possible</a><br>
<a href="http://www.hiteksoftware.com/mize/Knowledge/articles/049.htm" class="external">http://www.hiteksoftware.com/mize/Knowledge/articles/049.htm</a></p> Ruby master - Feature #8083: Exit status is limited to one-byte values which is invalid for Windowshttps://redmine.ruby-lang.org/issues/8083?journal_id=375912013-03-14T15:53:26Zusa (Usaku NAKAMURA)usa@garbagecollect.jp
<ul><li><strong>Tracker</strong> changed from <i>Bug</i> to <i>Feature</i></li><li><strong>Status</strong> changed from <i>Feedback</i> to <i>Assigned</i></li></ul><p>This may be not a bug but a feature.</p> Ruby master - Feature #8083: Exit status is limited to one-byte values which is invalid for Windowshttps://redmine.ruby-lang.org/issues/8083?journal_id=375972013-03-14T20:26:32Zrutsky (Vladimir Rutsky)rutsky.vladimir@gmail.com
<ul></ul><p>=begin<br>
I cannot find exact definition of possible exit codes on Windows, but here is ExitProcess function declaration [1]:</p>
<p>VOID WINAPI ExitProcess(<br>
<em>In</em> UINT uExitCode<br>
);</p>
<p>UINT type definition [2]:</p>
<p>An unsigned INT. The range is 0 through 4294967295 decimal.</p>
<p>GetExitCodeProcess declaration [3] (looks like it used in CRuby to get exit status):</p>
<p>BOOL WINAPI GetExitCodeProcess(<br>
<em>In</em> HANDLE hProcess,<br>
<em>Out</em> LPDWORD lpExitCode<br>
);</p>
<p>LPDWORD type definition [4]:</p>
<p>typedef DWORD *LPDWORD;</p>
<p>DWORD type definition [5]:</p>
<p>A 32-bit unsigned integer. The range is 0 through 4294967295 decimal.</p>
<p>Not sure about all Windows platforms, but at least on Windows 7 error codes in full 32-bit range can be retrieved in practice:</p>
<p>C:\Python27>python.exe -c "import ctypes, ctypes.wintypes; ctypes.windll.kernel32.ExitProcess(ctypes.wintypes.UINT(30))"</p>
<p>C:\Python27>echo %errorlevel%<br>
30</p>
<p>C:\Python27>python.exe -c "import ctypes, ctypes.wintypes; ctypes.windll.kernel32.ExitProcess(ctypes.wintypes.UINT(2**31 - 1))"</p>
<p>C:\Python27>echo %errorlevel%<br>
2147483647</p>
<p>C:\Python27>python.exe -c "import ctypes, ctypes.wintypes; ctypes.windll.kernel32.ExitProcess(ctypes.wintypes.UINT(2**31))"</p>
<p>C:\Python27>echo %errorlevel%<br>
-2147483648</p>
<p>C:\Python27>python.exe -c "import ctypes, ctypes.wintypes; ctypes.windll.kernel32.ExitProcess(ctypes.wintypes.UINT(2**32 - 1))"</p>
<p>C:\Python27>echo %errorlevel%<br>
-1</p>
<p>[1] <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms682658%28v=vs.85%29.aspx" class="external">http://msdn.microsoft.com/en-us/library/windows/desktop/ms682658%28v=vs.85%29.aspx</a></p>
<p>[2] <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751%28v=vs.85%29.aspx#UINT" class="external">http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751%28v=vs.85%29.aspx#UINT</a></p>
<p>[3] <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms683189%28v=vs.85%29.aspx" class="external">http://msdn.microsoft.com/en-us/library/windows/desktop/ms683189%28v=vs.85%29.aspx</a></p>
<p>[4] <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751%28v=vs.85%29.aspx#LPDWORD" class="external">http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751%28v=vs.85%29.aspx#LPDWORD</a></p>
<p>[5] <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751%28v=vs.85%29.aspx#DWORD" class="external">http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751%28v=vs.85%29.aspx#DWORD</a><br>
=end</p>