diff --git a/src/main.js b/src/main.js index 6d4fdca1e3..bfaf10549a 100644 --- a/src/main.js +++ b/src/main.js @@ -79,7 +79,7 @@ clearInterval = clearTimeout; findScript(base_directory, name, function (filename) { if (filename === null) { stderr.puts("Cannot find a script matching: " + name); - process.exit(1); + exit(1); } loadScript(filename, target, callback); }); @@ -137,7 +137,7 @@ clearInterval = clearTimeout; File.cat(filename, function (status, content) { if (status != 0) { stderr.puts("Error reading " + filename + ": " + File.strerror(status)); - process.exit(1); + exit(1); } var scaffold = new Scaffold(content, filename, target); diff --git a/src/node.cc b/src/node.cc index 567691366f..92f3c0370a 100644 --- a/src/node.cc +++ b/src/node.cc @@ -2,7 +2,6 @@ #include "net.h" #include "file.h" -#include "process.h" #include "http.h" #include "timer.h" @@ -124,6 +123,15 @@ ExecuteString(v8::Handle source, return scope.Close(result); } +NODE_METHOD(node_exit) +{ + int r = 0; + if (args.Length() > 0) + r = args[0]->IntegerValue(); + ::exit(r); + return Undefined(); +} + NODE_METHOD(compile) { if (args.Length() < 2) @@ -166,18 +174,9 @@ void node::fatal_exception (TryCatch &try_catch) { ReportException(&try_catch); - ev_unloop(EV_DEFAULT_UC_ EVUNLOOP_ALL); - exit_code = 1; -} - -void -node::exit (int code) -{ - exit_code = code; - ev_unloop(EV_DEFAULT_UC_ EVUNLOOP_ALL); + ::exit(1); } - static ev_async thread_pool_watcher; static void @@ -236,6 +235,7 @@ main (int argc, char *argv[]) NODE_SET_METHOD(node, "compile", compile); NODE_SET_METHOD(node, "debug", debug); + NODE_SET_METHOD(g, "exit", node_exit); Local arguments = Array::New(argc); for (int i = 0; i < argc; i++) { @@ -244,10 +244,10 @@ main (int argc, char *argv[]) } g->Set(String::New("ARGV"), arguments); + // BUILT-IN MODULES node::Init_net(g); node::Init_timer(g); - node::Init_process(g); node::Init_file(g); node::Init_http(g); diff --git a/src/node.h b/src/node.h index 74fb60a0d7..959175253a 100644 --- a/src/node.h +++ b/src/node.h @@ -15,7 +15,6 @@ namespace node { enum encoding {UTF8, RAW}; void fatal_exception (v8::TryCatch &try_catch); -void exit (int code); void eio_warmup (void); // call this before creating a new eio event. class ObjectWrap { diff --git a/src/process.cc b/src/process.cc deleted file mode 100644 index ba0c31fb16..0000000000 --- a/src/process.cc +++ /dev/null @@ -1,39 +0,0 @@ -#include "process.h" -#include "node.h" -#include -#include - -using namespace v8; - -static Handle -ExitCallback (const Arguments& args) -{ - int exit_code = 0; - if (args.Length() > 0) exit_code = args[0]->IntegerValue(); - exit(exit_code); - return Undefined(); -} - -static Handle -OnCallback (const Arguments& args) -{ - return Undefined(); -} - -void -node::Init_process (Handle target) -{ - HandleScope scope; - - Local process = ObjectTemplate::New()->NewInstance(); - - target->Set(String::NewSymbol("process"), process); - - // process.exit() - Local process_exit = FunctionTemplate::New(ExitCallback); - process->Set(String::NewSymbol("exit"), process_exit->GetFunction()); - - // process.on() - Local process_on = FunctionTemplate::New(OnCallback); - process->Set(String::NewSymbol("on"), process_exit->GetFunction()); -} diff --git a/src/process.h b/src/process.h deleted file mode 100644 index 4be64b516f..0000000000 --- a/src/process.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef node_process_h -#define node_process_h - -#include - -namespace node { - -void Init_process (v8::Handle target); - -} // namespace node -#endif diff --git a/test/test-pingpong.js b/test/test-pingpong.js index 780e5d9509..1c53f1f57e 100644 --- a/test/test-pingpong.js +++ b/test/test-pingpong.js @@ -45,7 +45,7 @@ function onLoad() { socket.connectTCP(12123, "127.0.0.1", function (status) { if(status != 0) - process.exit(1); + exit(1); socket.write("PING"); }); diff --git a/wscript b/wscript index 643b716acc..ccf20f9f9c 100644 --- a/wscript +++ b/wscript @@ -158,7 +158,6 @@ def build(bld): src/node.cc src/http.cc src/net.cc - src/process.cc src/file.cc src/timer.cc """