candera / shadowspawn

A Windows utility that mounts a shadow copy of the disk at a drive letter and then spawns an arbitrary command.
MIT License
184 stars 55 forks source link

ShadowSpawn should return the command's failure exit code #2

Closed candera closed 13 years ago

candera commented 13 years ago

Background

Currently, ShadowSpawn determines what error code to return based purely on its own error conditions. If the command it launches exits with a nonzero status, however, ShadowSpawn itself will exit with a zero status, effectively losing the failure. This is not desirable.

Acceptance Criteria

candera commented 13 years ago

We considered returning the calling program's exit code in cases where it returns nonzero, but ultimately decided that it was weird. And the called program could be returning an exit code that is the same as one that ShadowSpawn uses, which would lead to more confusion. The right thing seems to be to have a code that means "The called program barfed." The actual exit status of the called program is available in the debug spew.

candera commented 13 years ago

After thinking about it further, we realized that some programs (e.g. robocopy) actually return a nonzero exit status when they succeed. Evil but true. So what happens now is that if the launched program exits with a nonzero exit status, ShadowSpawn exits with that status plus 0x8000 (32768). That should allow us to tease out the error code of the underlying program in most cases.