Should the following work on a non-rooted, stock Froyo-running device?
I'm forking off a child process and attaching to the original parent
process using ptrace.
pid = fork();
if (pid == 0) {
pid = getppid(); /* get parent process id */
if (ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) {
int i = errno;
__android_log_print(ANDROID_LOG_INFO, "whatever",
"child: could not attach %d (%d)", pid, i);
}
}
On an emulator running 2.2 I'm able to attach to the parent process
correctly, but on a regular phone it fails and gives errno==1,
"Operation Not Permitted".
The uid and gid are the same for both processes (of course, after a
fork..), and the child process has ptrace capabilities, or at least
prctl(PR_CAPBSET_READ, CAP_SYS_PTRACE, 0, 0, 0) as written in [1]
returns 1.
Any ideas on what else I can check?
[1]
https://bug598155.bugzilla.mozilla.org/attachment.cgi?id=477044