Ingore SIGPIPE errors
If MTP exits unexpectedly, sending messages to add or remove a
storage device via Add_Remove_MTP_Storage was causing a crash.
Ignoring SIGPIPE allows us to more gracefully handle the error
instead of a total crash of TWRP.
Change-Id: I0a3f770f8b0f4bdbe10aa0ba857209b22b8668f7
diff --git a/twrp.cpp b/twrp.cpp
index 24a56f1..53aab7f 100644
--- a/twrp.cpp
+++ b/twrp.cpp
@@ -20,6 +20,7 @@
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
+#include <signal.h>
#include "cutils/properties.h"
extern "C" {
@@ -72,6 +73,8 @@
freopen(TMP_LOG_FILE, "a", stderr);
setbuf(stderr, NULL);
+ signal(SIGPIPE, SIG_IGN);
+
// Handle ADB sideload
if (argc == 3 && strcmp(argv[1], "--adbd") == 0) {
adb_main(argv[2]);