OSDN Git Service

Add default sigpipe handler for android (as suggested by Elliott Hughes).
authorRob Landley <rob@landley.net>
Thu, 30 Apr 2015 20:11:34 +0000 (15:11 -0500)
committerRob Landley <rob@landley.net>
Thu, 30 Apr 2015 20:11:34 +0000 (15:11 -0500)
main.c

diff --git a/main.c b/main.c
index 5702244..2fd22d4 100644 (file)
--- a/main.c
+++ b/main.c
@@ -183,8 +183,17 @@ void toybox_main(void)
   xputc('\n');
 }
 
+static void shutup_sigpipe(int i)
+{
+  // exit success from sigpipe to mollify overzealous crash reporting.
+  _exit(0);
+}
+
 int main(int argc, char *argv[])
 {
+  if (CFG_TOYBOX_ON_ANDROID) signal(SIGPIPE, shutup_sigpipe);
+  else signal(SIGPIPE, SIG_IGN);
+
   if (CFG_TOYBOX) {
     // Trim path off of command name
     *argv = basename(*argv);