diff --git a/debuggerd/client/debuggerd_client.cpp b/debuggerd/client/debuggerd_client.cpp index c357fd6d6..cb7cbbe0f 100644 --- a/debuggerd/client/debuggerd_client.cpp +++ b/debuggerd/client/debuggerd_client.cpp @@ -28,7 +28,9 @@ #include #include +#include #include +#include #include #include @@ -117,6 +119,20 @@ bool debuggerd_trigger_dump(pid_t pid, DebuggerdDumpType dump_type, unsigned int return false; } + std::string pipe_size_str; + int pipe_buffer_size = 1024 * 1024; + if (android::base::ReadFileToString("/proc/sys/fs/pipe-max-size", &pipe_size_str)) { + pipe_size_str = android::base::Trim(pipe_size_str); + + if (!android::base::ParseInt(pipe_size_str.c_str(), &pipe_buffer_size, 0)) { + LOG(FATAL) << "failed to parse pipe max size '" << pipe_size_str << "'"; + } + } + + if (fcntl(pipe_read.get(), F_SETPIPE_SZ, pipe_buffer_size) != pipe_buffer_size) { + PLOG(ERROR) << "failed to set pipe buffer size"; + } + if (send_fd(set_timeout(sockfd), &req, sizeof(req), std::move(pipe_write)) != sizeof(req)) { PLOG(ERROR) << "libdebuggerd_client: failed to send output fd to tombstoned"; return false; diff --git a/debuggerd/debuggerd_test.cpp b/debuggerd/debuggerd_test.cpp index 8c00b76a0..9008b95ac 100644 --- a/debuggerd/debuggerd_test.cpp +++ b/debuggerd/debuggerd_test.cpp @@ -119,6 +119,8 @@ static void tombstoned_intercept(pid_t target_pid, unique_fd* intercept_fd, uniq FAIL() << "failed to set pipe size: " << strerror(errno); } + ASSERT_GE(pipe_buffer_size, 1024 * 1024); + if (send_fd(intercept_fd->get(), &req, sizeof(req), std::move(output_pipe_write)) != sizeof(req)) { FAIL() << "failed to send output fd to tombstoned: " << strerror(errno); }