Let dumpstate die a normal death when receiving a singal
Having dumpstate not generate a crash report / tombstone makes
diagnosing crashes a bit harder. This change avoids calling _exit(3)
when receiving a signal, except for SIGPIPE which we just SIG_IGN.
Bug: 76120715
Test: dumpstate
Change-Id: I7bd986251f7174de77bdcfd4ff3ee26a1ef4afc7
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index bfd0f16..9648ede 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -1634,20 +1634,8 @@
ShowUsageAndExit();
}
-static void sig_handler(int) {
- _exit(EXIT_FAILURE);
-}
-
static void register_sig_handler() {
- struct sigaction sa;
- sigemptyset(&sa.sa_mask);
- sa.sa_flags = 0;
- sa.sa_handler = sig_handler;
- sigaction(SIGPIPE, &sa, NULL); // broken pipe
- sigaction(SIGSEGV, &sa, NULL); // segment fault
- sigaction(SIGINT, &sa, NULL); // ctrl-c
- sigaction(SIGTERM, &sa, NULL); // killed
- sigaction(SIGQUIT, &sa, NULL); // quit
+ signal(SIGPIPE, SIG_IGN);
}
bool Dumpstate::FinishZipFile() {