aboutsummaryrefslogtreecommitdiffstats
path: root/libcutils
diff options
context:
space:
mode:
authorErik Gilling <konkers@android.com>2009-11-05 15:52:30 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2009-11-05 15:52:30 -0800
commitac61a69b235110a17493f8e05e5a2467476965fc (patch)
treef9feef69b105dc39dc2cb3e37f67937962b17520 /libcutils
parent2c7548519fad680e867942aa1d38105e55fbd5c4 (diff)
parent9fdf607c20f9610e442baa87cac5479c98f9d200 (diff)
downloadsystem_core-ac61a69b235110a17493f8e05e5a2467476965fc.tar.gz
system_core-ac61a69b235110a17493f8e05e5a2467476965fc.tar.bz2
system_core-ac61a69b235110a17493f8e05e5a2467476965fc.zip
am 9fdf607c: am b63747d4: am f6eba8fa: cutils: make set_process_name set kernel thread name as well
Merge commit '9fdf607c20f9610e442baa87cac5479c98f9d200' * commit '9fdf607c20f9610e442baa87cac5479c98f9d200': cutils: make set_process_name set kernel thread name as well
Diffstat (limited to 'libcutils')
-rw-r--r--libcutils/process_name.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/libcutils/process_name.c b/libcutils/process_name.c
index 17f52e26..b235429d 100644
--- a/libcutils/process_name.c
+++ b/libcutils/process_name.c
@@ -22,6 +22,10 @@
#include <sys/stat.h>
#include <fcntl.h>
+#if defined(HAVE_PRCTL)
+#include <sys/prctl.h>
+#endif
+
#define PROCESS_NAME_DEVICE "/sys/qemu_trace/process_name"
static const char* process_name = "unknown";
@@ -35,10 +39,19 @@ void set_process_name(const char* new_name) {
}
// We never free the old name. Someone else could be using it.
- char* copy = (char*) malloc(strlen(new_name) + 1);
+ int len = strlen(new_name);
+ char* copy = (char*) malloc(len + 1);
strcpy(copy, new_name);
process_name = (const char*) copy;
+#if defined(HAVE_PRCTL)
+ if (len < 16) {
+ prctl(PR_SET_NAME, (unsigned long) new_name, 0, 0, 0);
+ } else {
+ prctl(PR_SET_NAME, (unsigned long) new_name + len - 15, 0, 0, 0);
+ }
+#endif
+
// If we know we are not running in the emulator, then return.
if (running_in_emulator == 0) {
return;