Browse Source

Stub out process.title

v0.7.4-release
Ryan Dahl 15 years ago
parent
commit
5185c15ef7
  1. 4
      doc/api.markdown
  2. 27
      src/node.cc
  3. 4
      src/platform.h
  4. 17
      src/platform_cygwin.cc
  5. 16
      src/platform_darwin.cc
  6. 16
      src/platform_freebsd.cc
  7. 17
      src/platform_linux.cc
  8. 16
      src/platform_none.cc
  9. 16
      src/platform_sunos.cc
  10. 4
      wscript

4
doc/api.markdown

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

27
src/node.cc

@ -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[]) { static void Load(int argc, char *argv[]) {
HandleScope scope; HandleScope scope;
@ -1514,6 +1532,12 @@ static void Load(int argc, char *argv[]) {
process = Persistent<Object>::New(process_template->GetFunction()->NewInstance()); process = Persistent<Object>::New(process_template->GetFunction()->NewInstance());
process->SetAccessor(String::New("title"),
ProcessTitleGetter,
ProcessTitleSetter);
// Add a reference to the global object // Add a reference to the global object
Local<Object> global = v8::Context::GetCurrent()->Global(); Local<Object> global = v8::Context::GetCurrent()->Global();
process->Set(String::NewSymbol("global"), global); process->Set(String::NewSymbol("global"), global);
@ -1733,6 +1757,9 @@ static void AtExit() {
int main(int argc, char *argv[]) { 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. // Parse a few arguments which are specific to Node.
node::ParseArgs(&argc, argv); node::ParseArgs(&argc, argv);
// Parse the rest of the args (up to the 'option_end_index' (where '--' was // Parse the rest of the args (up to the 'option_end_index' (where '--' was

4
src/platform.h

@ -5,6 +5,10 @@ namespace node {
class OS { class OS {
public: 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 GetMemory(size_t *rss, size_t *vsize);
static int GetExecutablePath(char* buffer, size_t* size); static int GetExecutablePath(char* buffer, size_t* size);
}; };

17
src/platform_cygwin.cc

@ -9,6 +9,23 @@ namespace node {
static char buf[MAXPATHLEN + 1]; 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) { int OS::GetMemory(size_t *rss, size_t *vsize) {
FILE *f = fopen("/proc/self/stat", "r"); FILE *f = fopen("/proc/self/stat", "r");
if (!f) return -1; if (!f) return -1;

16
src/platform_darwin.cc

@ -8,6 +8,22 @@
namespace node { 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 // Researched by Tim Becker and Michael Knight
// http://blog.kuriositaet.de/?p=257 // http://blog.kuriositaet.de/?p=257
int OS::GetMemory(size_t *rss, size_t *vsize) { int OS::GetMemory(size_t *rss, size_t *vsize) {

16
src/platform_freebsd.cc

@ -13,6 +13,22 @@
namespace node { 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) { int OS::GetMemory(size_t *rss, size_t *vsize) {
kvm_t *kd = NULL; kvm_t *kd = NULL;
struct kinfo_proc *kinfo = NULL; struct kinfo_proc *kinfo = NULL;

17
src/platform_linux.cc

@ -9,6 +9,23 @@ namespace node {
static char buf[MAXPATHLEN + 1]; 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) { int OS::GetMemory(size_t *rss, size_t *vsize) {
FILE *f = fopen("/proc/self/stat", "r"); FILE *f = fopen("/proc/self/stat", "r");
if (!f) return -1; if (!f) return -1;

16
src/platform_none.cc

@ -5,6 +5,22 @@
namespace node { 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) { int OS::GetMemory(size_t *rss, size_t *vsize) {
// Not implemented // Not implemented
*rss = 0; *rss = 0;

16
src/platform_sunos.cc

@ -24,6 +24,22 @@
namespace node { 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) { int OS::GetMemory(size_t *rss, size_t *vsize) {
pid_t pid = getpid(); pid_t pid = getpid();

4
wscript

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

Loading…
Cancel
Save