Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
Implement process.title for linux
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Aug 11, 2010
1 parent 5185c15 commit 06634f4
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/platform_linux.cc
Expand Up @@ -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;
}
Expand Down

0 comments on commit 06634f4

Please sign in to comment.