From 06634f48ebe64a3b21b45e16eefd59a50032dd0c Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 11 Aug 2010 12:44:35 -0700 Subject: [PATCH] Implement process.title for linux --- src/platform_linux.cc | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/platform_linux.cc b/src/platform_linux.cc index f2a1e84..d964d23 100644 --- a/src/platform_linux.cc +++ b/src/platform_linux.cc @@ -4,23 +4,37 @@ #include // for MAXPATHLEN #include // getpagesize +/* SetProcessTitle */ +#include +#include +#include // free +#include // 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; } -- 2.7.4