Merge "Fix pointer arith."
diff --git a/adb/adb.c b/adb/adb.c
index 60568f5..001fae1 100644
--- a/adb/adb.c
+++ b/adb/adb.c
@@ -976,13 +976,14 @@
         ** AID_INET to diagnose network issues (netcfg, ping)
         ** AID_GRAPHICS to access the frame buffer
         ** AID_NET_BT and AID_NET_BT_ADMIN to diagnose bluetooth (hcidump)
+        ** AID_SDCARD_R to allow reading from the SD card
         ** AID_SDCARD_RW to allow writing to the SD card
         ** AID_MOUNT to allow unmounting the SD card before rebooting
         ** AID_NET_BW_STATS to read out qtaguid statistics
         */
         gid_t groups[] = { AID_ADB, AID_LOG, AID_INPUT, AID_INET, AID_GRAPHICS,
-                           AID_NET_BT, AID_NET_BT_ADMIN, AID_SDCARD_RW, AID_MOUNT,
-                           AID_NET_BW_STATS };
+                           AID_NET_BT, AID_NET_BT_ADMIN, AID_SDCARD_R, AID_SDCARD_RW,
+                           AID_MOUNT, AID_NET_BW_STATS };
         if (setgroups(sizeof(groups)/sizeof(groups[0]), groups) != 0) {
             exit(1);
         }
diff --git a/debuggerd/debuggerd.c b/debuggerd/debuggerd.c
index 0f05bfd..662683a 100644
--- a/debuggerd/debuggerd.c
+++ b/debuggerd/debuggerd.c
@@ -64,6 +64,7 @@
     case SIGBUS:     return "SIGBUS";
     case SIGFPE:     return "SIGFPE";
     case SIGSEGV:    return "SIGSEGV";
+    case SIGPIPE:    return "SIGPIPE";
     case SIGSTKFLT:  return "SIGSTKFLT";
     case SIGSTOP:    return "SIGSTOP";
     default:         return "?";
@@ -719,7 +720,8 @@
     request_t request;
     int status = read_request(fd, &request);
     if (!status) {
-        XLOG("BOOM: pid=%d uid=%d gid=%d tid=%d\n", pid, uid, gid, tid);
+        XLOG("BOOM: pid=%d uid=%d gid=%d tid=%d\n",
+            request.pid, request.uid, request.gid, request.tid);
 
         /* At this point, the thread that made the request is blocked in
          * a read() call.  If the thread has crashed, then this gives us
@@ -776,8 +778,16 @@
                     case SIGBUS:
                     case SIGFPE:
                     case SIGSEGV:
+                    case SIGPIPE:
                     case SIGSTKFLT: {
                         XLOG("stopped -- fatal signal\n");
+                        /*
+                         * Send a SIGSTOP to the process to make all of
+                         * the non-signaled threads stop moving.  Without
+                         * this we get a lot of "ptrace detach failed:
+                         * No such process".
+                         */
+                        kill(request.pid, SIGSTOP);
                         /* don't dump sibling threads when attaching to GDB because it
                          * makes the process less reliable, apparently... */
                         tombstone_path = engrave_tombstone(request.pid, request.tid,
@@ -861,8 +871,8 @@
     signal(SIGBUS, SIG_DFL);
     signal(SIGFPE, SIG_DFL);
     signal(SIGSEGV, SIG_DFL);
-    signal(SIGSTKFLT, SIG_DFL);
     signal(SIGPIPE, SIG_DFL);
+    signal(SIGSTKFLT, SIG_DFL);
 
     logsocket = socket_local_client("logd",
             ANDROID_SOCKET_NAMESPACE_ABSTRACT, SOCK_DGRAM);
diff --git a/include/private/android_filesystem_config.h b/include/private/android_filesystem_config.h
index 0344b5c..a3d5e62 100644
--- a/include/private/android_filesystem_config.h
+++ b/include/private/android_filesystem_config.h
@@ -61,6 +61,7 @@
 #define AID_UNUSED2       1025  /* deprecated, DO NOT USE */
 #define AID_DRMRPC        1026  /* group for drm rpc */
 #define AID_NFC           1027  /* nfc subsystem */
+#define AID_SDCARD_R      1028  /* external storage read access */
 
 #define AID_SHELL         2000  /* adb and debug shell user */
 #define AID_CACHE         2001  /* cache access */