adbd's children should have SIGPIPE set to SIG_DFL.
POSIX lets you choose whether or not SIGPIPE disposition is inherited,
and Linux chose "yes". Work around that.
Bug: http://b/35209888
Test: "ps -A | head" without the toybox workaround
Change-Id: I6b5afa3d87eb2af04b24c6c37fa338ab60ad2336
diff --git a/adb/shell_service.cpp b/adb/shell_service.cpp
index 4975fab..d4f334b 100644
--- a/adb/shell_service.cpp
+++ b/adb/shell_service.cpp
@@ -320,6 +320,10 @@
parent_error_sfd.reset(-1);
close_on_exec(child_error_sfd);
+ // adbd sets SIGPIPE to SIG_IGN to get EPIPE instead, and Linux propagates that to child
+ // processes, so we need to manually reset back to SIG_DFL here (http://b/35209888).
+ signal(SIGPIPE, SIG_DFL);
+
if (command_.empty()) {
execle(_PATH_BSHELL, _PATH_BSHELL, "-", nullptr, cenv.data());
} else {