Merge "Handle long process names correctly."
This commit is contained in:
@@ -299,9 +299,7 @@ int main(int argc, char* const argv[])
|
||||
}
|
||||
|
||||
if (!niceName.isEmpty()) {
|
||||
const char* procName = niceName.string();
|
||||
pthread_setname_np(pthread_self(), procName);
|
||||
runtime.setArgv0(procName);
|
||||
runtime.setArgv0(niceName.string(), true /* setProcName */);
|
||||
}
|
||||
|
||||
if (zygote) {
|
||||
|
||||
@@ -269,7 +269,15 @@ AndroidRuntime::~AndroidRuntime()
|
||||
return jniRegisterNativeMethods(env, className, gMethods, numMethods);
|
||||
}
|
||||
|
||||
void AndroidRuntime::setArgv0(const char* argv0) {
|
||||
void AndroidRuntime::setArgv0(const char* argv0, bool setProcName) {
|
||||
if (setProcName) {
|
||||
int len = strlen(argv0);
|
||||
if (len < 15) {
|
||||
pthread_setname_np(pthread_self(), argv0);
|
||||
} else {
|
||||
pthread_setname_np(pthread_self(), argv0 + len - 15);
|
||||
}
|
||||
}
|
||||
memset(mArgBlockStart, 0, mArgBlockLength);
|
||||
strlcpy(mArgBlockStart, argv0, mArgBlockLength);
|
||||
}
|
||||
|
||||
@@ -412,9 +412,7 @@ void android_os_Process_setArgV0(JNIEnv* env, jobject clazz, jstring name)
|
||||
}
|
||||
|
||||
if (!name8.isEmpty()) {
|
||||
const char* procName = name8.string();
|
||||
pthread_setname_np(pthread_self(), procName);
|
||||
AndroidRuntime::getRuntime()->setArgv0(procName);
|
||||
AndroidRuntime::getRuntime()->setArgv0(name8.string(), true /* setProcName */);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public:
|
||||
Tool,
|
||||
};
|
||||
|
||||
void setArgv0(const char* argv0);
|
||||
void setArgv0(const char* argv0, bool setProcName = false);
|
||||
void addOption(const char* optionString, void* extra_info = NULL);
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user