Re: Interpreting exit code given to "exit" procedure Lassi Kortela 14 Aug 2019 20:50 UTC
> I think we should say that when an R7RS system implements > SRFI 170, the R7RS exit and emergency-exit procedures must interpret an > exact integer argument modulo 255 as a Posix exit argument. Agreed, but not sure about the modulo 255 part. That's just uncivilized :p A Lisp is not supposed to implicitly mod people's integers. Here's the Windows situation: * ExitProcess function <https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-exitprocess> * GetExitCodeProcess function <https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-getexitcodeprocess> They use UINT / DWORD which is 32 bits (or 32/64?). The docs don't say anything about modulo of clamping. But apparently 259 is an unambiguous exit code. So even on Windows, values outside 0..255 are hazardous. Also, if Wine is emulating a Windows program on Unix, one might expect the exit code of the Windows program to be truncated to fit the Unix convention. More trouble comes from the fact that the Posix waitid() extension allows people to actually utilize the bits of an int beyond the first 8. Though any programmer who does so is probably asking for trouble. What about portability to other systems that lop off the extra bits, or porting 64-bit ints to 32-bit ints? I don't mind if Scheme doesn't support any of this stuff. Gambit's stance of erroring on anything outside 0..255 is starting to look like the least objectionable compromise. We could mod the exit values like Unix, but that's not intuitive to anyone except Unix diehards. 256 aliasing to a successful exit (0) is particularly worrisome.