Psychic debugging: Why does ExitProcess(1) produce an exit code of zero?

Raymond Chen

Here’s a question that came from a customer. By now, you should already have the necessary psychic powers to answer it.

Our program calls ExitProcess(1) to indicate that it exited unsuccessfully. The process that launched our program waits for the program to exit and then calls GetExitCodeProcess to retrieve the exit code. The function succeeds, but the exit code is zero! How can this be?

Hint: Read about how processes terminate on Windows XP.


Discussion is closed.

Feedback usabilla icon