Merge "debuggerd: call setsid in our children."
am: 371180bb72
Change-Id: Iee5d2f928d3f99d86657a838a9f73faa6674a237
diff --git a/debuggerd/crash_dump.cpp b/debuggerd/crash_dump.cpp
index 82ba0a1..c608a8c 100644
--- a/debuggerd/crash_dump.cpp
+++ b/debuggerd/crash_dump.cpp
@@ -363,6 +363,12 @@
DefuseSignalHandlers();
InstallSigPipeHandler();
+ // There appears to be a bug in the kernel where our death causes SIGHUP to
+ // be sent to our process group if we exit while it has stopped jobs (e.g.
+ // because of wait_for_gdb). Use setsid to create a new process group to
+ // avoid hitting this.
+ setsid();
+
atrace_begin(ATRACE_TAG, "before reparent");
pid_t target_process = getppid();
diff --git a/debuggerd/handler/debuggerd_handler.cpp b/debuggerd/handler/debuggerd_handler.cpp
index bca5e36..598ea85 100644
--- a/debuggerd/handler/debuggerd_handler.cpp
+++ b/debuggerd/handler/debuggerd_handler.cpp
@@ -268,8 +268,15 @@
_exit(errno);
}
- // Exit immediately on both sides of the fork.
- // crash_dump is ptracing us, so it'll get to do whatever it wants in between.
+ // crash_dump is ptracing both sides of the fork; it'll let the parent exit,
+ // but keep the orphan stopped to peek at its memory.
+
+ // There appears to be a bug in the kernel where our death causes SIGHUP to
+ // be sent to our process group if we exit while it has stopped jobs (e.g.
+ // because of wait_for_gdb). Use setsid to create a new process group to
+ // avoid hitting this.
+ setsid();
+
_exit(0);
}