Fix deadlock when killing adb bugreport
Leave default signal handler (terminate) for parent process,
add SIG_IGN as signal handler for children and let them
go down when the parent gets SIGPIPE.
Bug: 17109154
Change-Id: Id33db3e97a32f289eb2a9a1a0ca8acbe3dcd285d
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c
index 342dc89..ffc8714 100644
--- a/cmds/dumpstate/dumpstate.c
+++ b/cmds/dumpstate/dumpstate.c
@@ -378,8 +378,8 @@
}
static void sigpipe_handler(int n) {
- (void)n;
- exit(EXIT_FAILURE);
+ // don't complain to stderr or stdout
+ _exit(EXIT_FAILURE);
}
int main(int argc, char *argv[]) {
@@ -404,10 +404,12 @@
}
ALOGI("begin\n");
+
memset(&sigact, 0, sizeof(sigact));
sigact.sa_handler = sigpipe_handler;
sigaction(SIGPIPE, &sigact, NULL);
+
/* set as high priority, and protect from OOM killer */
setpriority(PRIO_PROCESS, 0, -20);
FILE *oom_adj = fopen("/proc/self/oom_adj", "w");