diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2010-08-11 12:44:35 -0700 |
---|---|---|
committer | Ryan Dahl <ry@tinyclouds.org> | 2010-08-11 13:15:00 -0700 |
commit | 06634f48ebe64a3b21b45e16eefd59a50032dd0c (patch) | |
tree | 0cdd73db95b8066442d6bf3845a32bb49b49277d /src/platform_linux.cc | |
parent | 5185c15ef7473a02cb8d35237779a626156a797c (diff) | |
download | node-new-06634f48ebe64a3b21b45e16eefd59a50032dd0c.tar.gz |
Implement process.title for linux
Diffstat (limited to 'src/platform_linux.cc')
-rw-r--r-- | src/platform_linux.cc | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/platform_linux.cc b/src/platform_linux.cc index f2a1e84324..d964d23600 100644 --- a/src/platform_linux.cc +++ b/src/platform_linux.cc @@ -4,23 +4,37 @@ #include <sys/param.h> // for MAXPATHLEN #include <unistd.h> // getpagesize +/* SetProcessTitle */ +#include <sys/prctl.h> +#include <linux/prctl.h> +#include <stdlib.h> // free +#include <string.h> // strdup + namespace node { static char buf[MAXPATHLEN + 1]; +static char *process_title; char** OS::SetupArgs(int argc, char *argv[]) { + process_title = strdup(argv[0]); return argv; } void OS::SetProcessTitle(char *title) { - ; + if (process_title) free(process_title); + process_title = strdup(title); + prctl(PR_SET_NAME, process_title); } const char* OS::GetProcessTitle(int *len) { + if (process_title) { + *len = strlen(process_title); + return process_title; + } *len = 0; return NULL; } |