Check that PR_SET_NAME is defined.

Avoids breaking the build with older (pre-2006) linux kernels.
Raises a JS exception if the script tries to assign to `process.title`.

Fixes #840.
pull/22966/head
Ben Noordhuis 2011-07-04 14:29:59 +02:00
parent 8e0d788842
commit bd0baf2338
1 changed files with 6 additions and 0 deletions

View File

@ -64,9 +64,15 @@ char** Platform::SetupArgs(int argc, char *argv[]) {
void Platform::SetProcessTitle(char *title) { void Platform::SetProcessTitle(char *title) {
#ifdef PR_SET_NAME
if (process_title) free(process_title); if (process_title) free(process_title);
process_title = strdup(title); process_title = strdup(title);
prctl(PR_SET_NAME, process_title); prctl(PR_SET_NAME, process_title);
#else
Local<Value> ex = Exception::Error(
String::New("'process.title' is not writable on your system, sorry."));
ThrowException(ex); // Safe, this method is only called from the main thread.
#endif
} }