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
This commit is contained in:
parent
9cb2e2eb8c
commit
0915f23d5f
|
@ -274,6 +274,7 @@ cc_binary {
|
|||
"libbase",
|
||||
"libdebuggerd_client",
|
||||
"liblog",
|
||||
"libprocinfo",
|
||||
"libselinux",
|
||||
],
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue