diff options
author | John Michelau <w14107@motorola.com> | 2013-05-06 16:42:02 -0500 |
---|---|---|
committer | John Michelau <w14107@motorola.com> | 2013-05-28 14:20:59 -0500 |
commit | 885f888c55587e9366542b5155a06c321cde175a (patch) | |
tree | f33fdaf6aa82198e9d77ddef483c38b31f9c3f49 | |
parent | e8fed71da2d3e03ef933d308520bab5b860f05aa (diff) | |
download | native-885f888c55587e9366542b5155a06c321cde175a.tar.gz |
Exit dumpstate on SIGPIPE to avoid cascading child crashes
When dumpstate ignores SIGPIPE it can lead to a cascade of tombstones /
coredumps since many of its children don't handle or ignore it. It's
best to just exit dumpstate once the pipe is broken.
Change-Id: Ic0c57ecf4171f0c0a07837e51c41cb1876e1350c
-rw-r--r-- | cmds/dumpstate/dumpstate.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/cmds/dumpstate/dumpstate.c b/cmds/dumpstate/dumpstate.c index 55a36c2308..dbe98322c3 100644 --- a/cmds/dumpstate/dumpstate.c +++ b/cmds/dumpstate/dumpstate.c @@ -314,7 +314,13 @@ static void usage() { ); } +static void sigpipe_handler(int n) { + (void)n; + exit(EXIT_FAILURE); +} + int main(int argc, char *argv[]) { + struct sigaction sigact; int do_add_date = 0; int do_compress = 0; int do_vibrate = 1; @@ -334,7 +340,9 @@ int main(int argc, char *argv[]) { } ALOGI("begin\n"); - signal(SIGPIPE, SIG_IGN); + 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); |