am 8e312e81: Merge change Ia5109a87 into eclair
Merge commit '8e312e8160ef0cae569b6127591ee72c70bfda41' into eclair-mr2
* commit '8e312e8160ef0cae569b6127591ee72c70bfda41':
process: Add debug code to log process group transitions
diff --git a/core/jni/android_util_Process.cpp b/core/jni/android_util_Process.cpp
index 5b6c7ea..7c627c1 100644
--- a/core/jni/android_util_Process.cpp
+++ b/core/jni/android_util_Process.cpp
@@ -51,6 +51,8 @@
#undef __KERNEL__
#endif
+#define POLICY_DEBUG 1
+
using namespace android;
static void signalExceptionForPriorityError(JNIEnv* env, jobject obj, int err)
@@ -212,6 +214,26 @@
return;
}
+#if POLICY_DEBUG
+ char cmdline[32];
+ int fd;
+
+ strcpy(cmdline, "unknown");
+
+ sprintf(proc_path, "/proc/%d/cmdline", pid);
+ fd = open(proc_path, O_RDONLY);
+ if (fd >= 0) {
+ int rc = read(fd, cmdline, sizeof(cmdline)-1);
+ cmdline[rc] = 0;
+ close(fd);
+ }
+
+ if (grp == ANDROID_TGROUP_BG_NONINTERACT) {
+ LOGD("setProcessGroup: vvv pid %d (%s)", pid, cmdline);
+ } else {
+ LOGD("setProcessGroup: ^^^ pid %d (%s)", pid, cmdline);
+ }
+#endif
sprintf(proc_path, "/proc/%d/task", pid);
if (!(d = opendir(proc_path))) {
// If the process exited on us, don't generate an exception