diff options
Diffstat (limited to 'common-main.c')
-rw-r--r-- | common-main.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/common-main.c b/common-main.c index 29fb7452f8..b6124dd2c2 100644 --- a/common-main.c +++ b/common-main.c @@ -55,10 +55,22 @@ int main(int argc, const char **argv) result = cmd_main(argc, argv); + /* Not exit(3), but a wrapper calling our common_exit() */ + exit(result); +} + +/* We wrap exit() to call common_exit() in git-compat-util.h */ +int common_exit(const char *file, int line, int code) +{ /* - * We define exit() to call trace2_cmd_exit_fl() in - * git-compat-util.h. Whether we reach this or exit() - * elsewhere we'll always run our trace2 exit handler. + * For non-POSIX systems: Take the lowest 8 bits of the "code" + * to e.g. turn -1 into 255. On a POSIX system this is + * redundant, see exit(3) and wait(2), but as it doesn't harm + * anything there we don't need to guard this with an "ifdef". */ - exit(result); + code &= 0xff; + + trace2_cmd_exit_fl(file, line, code); + + return code; } |