linux: install handler and log errors on prctl failure
Change-Id: Ifef2123e77923682a4b48f5d740cb2f0bb07b3de
Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/1972311
Commit-Queue: Joshua Peraza <jperaza@chromium.org>
Reviewed-by: Mark Mentovai <mark@chromium.org>
GitOrigin-RevId: 4dd9124e2fa42c53e137cf831e5d9193f189b543
diff --git a/client/crashpad_client_linux.cc b/client/crashpad_client_linux.cc
index 2adcefc..98c3d09 100644
--- a/client/crashpad_client_linux.cc
+++ b/client/crashpad_client_linux.cc
@@ -16,6 +16,7 @@
#include <fcntl.h>
#include <stdlib.h>
+#include <sys/prctl.h>
#include <sys/socket.h>
#include <sys/syscall.h>
#include <sys/types.h>
@@ -290,9 +291,17 @@
}
pid = creds.pid;
}
- if (pid > 0 && client.SetPtracer(pid) != 0) {
- LOG(ERROR) << "failed to set ptracer";
- return false;
+ if (pid > 0 && prctl(PR_SET_PTRACER, pid, 0, 0, 0) != 0) {
+ PLOG(WARNING) << "prctl";
+ // TODO(jperaza): If this call to set the ptracer failed, it might be
+ // possible to try again just before a dump request, in case the
+ // environment has changed. Revisit ExceptionHandlerClient::SetPtracer()
+ // and consider saving the result of this call in ExceptionHandlerClient
+ // or as a member in this signal handler. ExceptionHandlerClient hasn't
+ // been responsible for maintaining state and a new ExceptionHandlerClient
+ // has been constructed as a local whenever a client needs to communicate
+ // with the handler. ExceptionHandlerClient lifetimes and ownership will
+ // need to be reconsidered if it becomes responsible for state.
}
sock_to_handler_.reset(sock.release());
handler_pid_ = pid;