diff options
author | Timothy J Fontaine <tjfontaine@gmail.com> | 2013-08-21 11:15:21 -0700 |
---|---|---|
committer | Timothy J Fontaine <tjfontaine@gmail.com> | 2013-08-21 11:15:21 -0700 |
commit | a784abaff631449533d44846987c1537c080e03d (patch) | |
tree | 0982d9a92450edb9e46ba683d75eb7822ea004b3 /deps/uv/src/unix/darwin-proctitle.c | |
parent | 41f55dc59b423b8b76e6f7971fd8f3a326a6fbad (diff) | |
download | android-node-v8-a784abaff631449533d44846987c1537c080e03d.tar.gz android-node-v8-a784abaff631449533d44846987c1537c080e03d.tar.bz2 android-node-v8-a784abaff631449533d44846987c1537c080e03d.zip |
uv: Upgrade to v0.11.8
Diffstat (limited to 'deps/uv/src/unix/darwin-proctitle.c')
-rw-r--r-- | deps/uv/src/unix/darwin-proctitle.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/deps/uv/src/unix/darwin-proctitle.c b/deps/uv/src/unix/darwin-proctitle.c index 56c141766c..90b2e41882 100644 --- a/deps/uv/src/unix/darwin-proctitle.c +++ b/deps/uv/src/unix/darwin-proctitle.c @@ -18,6 +18,10 @@ * IN THE SOFTWARE. */ +#include <dlfcn.h> +#include <errno.h> +#include <stdlib.h> + #include <TargetConditionals.h> #if !TARGET_OS_IPHONE @@ -26,9 +30,30 @@ #endif +static int uv__pthread_setname_np(const char* name) { + int (*dynamic_pthread_setname_np)(const char* name); + char namebuf[64]; /* MAXTHREADNAMESIZE */ + int err; + + /* pthread_setname_np() first appeared in OS X 10.6 and iOS 3.2. */ + dynamic_pthread_setname_np = dlsym(RTLD_DEFAULT, "pthread_setname_np"); + if (dynamic_pthread_setname_np == NULL) + return -ENOSYS; + + strncpy(namebuf, name, sizeof(namebuf) - 1); + namebuf[sizeof(namebuf) - 1] = '\0'; + + err = dynamic_pthread_setname_np(namebuf); + if (err) + return -err; + + return 0; +} + + int uv__set_process_title(const char* title) { #if TARGET_OS_IPHONE - return -ENOSYS; + return uv__pthread_setname_np(title); #else typedef CFTypeRef (*LSGetCurrentApplicationASNType)(void); typedef OSStatus (*LSSetApplicationInformationItemType)(int, @@ -84,6 +109,8 @@ int uv__set_process_title(const char* title) { if (err != noErr) return -ENOENT; + uv__pthread_setname_np(title); /* Don't care if it fails. */ + return 0; #endif /* !TARGET_OS_IPHONE */ } |