Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 885f888c authored by John Michelau's avatar John Michelau
Browse files

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
parent e8fed71d
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -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);