summaryrefslogtreecommitdiff
path: root/debuggerd/debuggerd.cpp
diff options
context:
space:
mode:
authorJosh Gao <jmgao@google.com>2017-06-27 14:08:05 -0700
committerJosh Gao <jmgao@google.com>2017-06-27 15:06:57 -0700
commit0915f23d5f841a54c511157e16dc514080248f7b (patch)
treebffd2ead8ce80a136a203fd68313a6f808f09ff5 /debuggerd/debuggerd.cpp
parent9cb2e2eb8cefcfca5133d01f29ab29005e1f2a46 (diff)
debuggerd: diagnostics for dumps that are guaranteed to fail.
Print diagnostics when the user requests a dump that is guaranteed to fail, such as trying to dump a process you can't send a signal to. Bug: http://b/63008395 Change-Id: I5c6bf2a5751f858e0534990b8d2ab6932eb9f11d Test: manually tested
Diffstat (limited to 'debuggerd/debuggerd.cpp')
-rw-r--r--debuggerd/debuggerd.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/debuggerd/debuggerd.cpp b/debuggerd/debuggerd.cpp
index 6298ace9d..0cc5f69cf 100644
--- a/debuggerd/debuggerd.cpp
+++ b/debuggerd/debuggerd.cpp
@@ -27,6 +27,7 @@
#include <android-base/parseint.h>
#include <android-base/unique_fd.h>
#include <debuggerd/client.h>
+#include <procinfo/process.h>
#include <selinux/selinux.h>
#include "util.h"
@@ -66,6 +67,24 @@ int main(int argc, char* argv[]) {
usage(1);
}
+ if (getuid() != 0) {
+ errx(1, "root is required");
+ }
+
+ // Check to see if the process exists and that we can actually send a signal to it.
+ android::procinfo::ProcessInfo proc_info;
+ if (!android::procinfo::GetProcessInfo(pid, &proc_info)) {
+ err(1, "failed to fetch info for process %d", pid);
+ }
+
+ if (proc_info.state == android::procinfo::kProcessStateZombie) {
+ errx(1, "process %d is a zombie", pid);
+ }
+
+ if (kill(pid, 0) != 0) {
+ err(1, "cannot send signal to process %d", pid);
+ }
+
unique_fd piperead, pipewrite;
if (!Pipe(&piperead, &pipewrite)) {
err(1, "failed to create pipe");