From 6044ac7e5ea249edaae773f44d730d9a70eb71a6 Mon Sep 17 00:00:00 2001 From: Kevin Ballard Date: Mon, 27 Oct 2014 17:23:08 -0700 Subject: [PATCH] Fix 3rd arg to PROCESS_EXIT event for %self The PROCESS_EXIT event takes 3 args: event name, pid, status. However, when fish is exiting, the PROCESS_EXIT is instead given the status of whether the last commandline parsed successfully. Change it to use the same value that fish itself is going to exit with. --- fish.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fish.cpp b/fish.cpp index f5420e8aa..467ae7878 100644 --- a/fish.cpp +++ b/fish.cpp @@ -523,7 +523,9 @@ int main(int argc, char **argv) } } - proc_fire_event(L"PROCESS_EXIT", EVENT_EXIT, getpid(), res); + int exit_status = res ? STATUS_UNKNOWN_COMMAND : proc_get_last_status(); + + proc_fire_event(L"PROCESS_EXIT", EVENT_EXIT, getpid(), exit_status); restore_term_mode(); restore_term_foreground_process_group(); @@ -543,6 +545,6 @@ int main(int argc, char **argv) if (g_log_forks) printf("%d: g_fork_count: %d\n", __LINE__, g_fork_count); - exit_without_destructors(res ? STATUS_UNKNOWN_COMMAND : proc_get_last_status()); + exit_without_destructors(exit_status); return EXIT_FAILURE; //above line should always exit }