This commit is contained in:
Ryan Dahl 2010-06-18 00:26:49 -07:00
Родитель 49888a01c3
Коммит 5185c15ef7
10 изменённых файлов: 133 добавлений и 4 удалений

Просмотреть файл

@ -750,6 +750,10 @@ The PID of the process.
console.log('This process is pid ' + process.pid);
### process.title
Getter/setter to set what is displayed in 'ps'.
### process.platform

Просмотреть файл

@ -1506,6 +1506,24 @@ static Handle<Value> Binding(const Arguments& args) {
}
static Handle<Value> ProcessTitleGetter(Local<String> property,
const AccessorInfo& info) {
HandleScope scope;
int len;
const char *s = OS::GetProcessTitle(&len);
return scope.Close(s ? String::New(s, len) : String::Empty());
}
static void ProcessTitleSetter(Local<String> property,
Local<Value> value,
const AccessorInfo& info) {
HandleScope scope;
String::Utf8Value title(value->ToString());
OS::SetProcessTitle(*title);
}
static void Load(int argc, char *argv[]) {
HandleScope scope;
@ -1514,6 +1532,12 @@ static void Load(int argc, char *argv[]) {
process = Persistent<Object>::New(process_template->GetFunction()->NewInstance());
process->SetAccessor(String::New("title"),
ProcessTitleGetter,
ProcessTitleSetter);
// Add a reference to the global object
Local<Object> global = v8::Context::GetCurrent()->Global();
process->Set(String::NewSymbol("global"), global);
@ -1733,6 +1757,9 @@ static void AtExit() {
int main(int argc, char *argv[]) {
// Hack aroung with the argv pointer. Used for process.title = "blah".
argv = node::OS::SetupArgs(argc, argv);
// Parse a few arguments which are specific to Node.
node::ParseArgs(&argc, argv);
// Parse the rest of the args (up to the 'option_end_index' (where '--' was

Просмотреть файл

@ -5,6 +5,10 @@ namespace node {
class OS {
public:
static char** SetupArgs(int argc, char *argv[]);
static void SetProcessTitle(char *title);
static const char* GetProcessTitle(int *len);
static int GetMemory(size_t *rss, size_t *vsize);
static int GetExecutablePath(char* buffer, size_t* size);
};

Просмотреть файл

@ -9,6 +9,23 @@ namespace node {
static char buf[MAXPATHLEN + 1];
char** OS::SetupArgs(int argc, char *argv[]) {
return argv;
}
void OS::SetProcessTitle(char *title) {
;
}
const char* OS::GetProcessTitle(int *len) {
*len = 0;
return NULL;
}
int OS::GetMemory(size_t *rss, size_t *vsize) {
FILE *f = fopen("/proc/self/stat", "r");
if (!f) return -1;

Просмотреть файл

@ -8,6 +8,22 @@
namespace node {
char** OS::SetupArgs(int argc, char *argv[]) {
return argv;
}
void OS::SetProcessTitle(char *title) {
;
}
const char* OS::GetProcessTitle(int *len) {
*len = 0;
return NULL;
}
// Researched by Tim Becker and Michael Knight
// http://blog.kuriositaet.de/?p=257
int OS::GetMemory(size_t *rss, size_t *vsize) {

Просмотреть файл

@ -13,6 +13,22 @@
namespace node {
char** OS::SetupArgs(int argc, char *argv[]) {
return argv;
}
void OS::SetProcessTitle(char *title) {
;
}
const char* OS::GetProcessTitle(int *len) {
*len = 0;
return NULL;
}
int OS::GetMemory(size_t *rss, size_t *vsize) {
kvm_t *kd = NULL;
struct kinfo_proc *kinfo = NULL;

Просмотреть файл

@ -9,6 +9,23 @@ namespace node {
static char buf[MAXPATHLEN + 1];
char** OS::SetupArgs(int argc, char *argv[]) {
return argv;
}
void OS::SetProcessTitle(char *title) {
;
}
const char* OS::GetProcessTitle(int *len) {
*len = 0;
return NULL;
}
int OS::GetMemory(size_t *rss, size_t *vsize) {
FILE *f = fopen("/proc/self/stat", "r");
if (!f) return -1;

Просмотреть файл

@ -5,6 +5,22 @@
namespace node {
char** OS::SetupArgs(int argc, char *argv[]) {
return argv;
}
void OS::SetProcessTitle(char *title) {
;
}
const char* OS::GetProcessTitle(int *len) {
*len = 0;
return NULL;
}
int OS::GetMemory(size_t *rss, size_t *vsize) {
// Not implemented
*rss = 0;

Просмотреть файл

@ -24,6 +24,22 @@
namespace node {
char** OS::SetupArgs(int argc, char *argv[]) {
return argv;
}
void OS::SetProcessTitle(char *title) {
;
}
const char* OS::GetProcessTitle(int *len) {
*len = 0;
return NULL;
}
int OS::GetMemory(size_t *rss, size_t *vsize) {
pid_t pid = getpid();

Просмотреть файл

@ -187,12 +187,8 @@ def configure(conf):
if not conf.check(lib='nsl', uselib_store="NSL"):
conf.fatal("Cannot find nsl library")
conf.sub_config('deps/libeio')
if conf.env['USE_SHARED_V8']:
v8_includes = [];
if o.shared_v8_includes: v8_includes.append(o.shared_v8_includes);