diff options
Diffstat (limited to 'debuggerd/debuggerd.cpp')
-rw-r--r-- | debuggerd/debuggerd.cpp | 19 |
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"); |