One more note about exit statuses

May 19, 2010

Last week, I mentioned in passing that Windows allows the full range of 32-bit exit codes. That’s true, but only if you directly call ExitProcess() (or its less-friendly kin TerminateProcess()).

If you just call exit() (or return from main(), which implicitly calls exit()), then like in the *NIX world, you only get the bottom 8 bits of the exit status—see MSDN’s exit() documentation. So for portability’s sake, don’t use exit statuses above 255 unless you really, really need to.

Comments are closed.