summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan <ry@tinyclouds.org>2009-04-29 11:09:32 +0200
committerRyan <ry@tinyclouds.org>2009-04-29 11:09:32 +0200
commit0f5170339c0a504739b8de44eb8ca206a0340f94 (patch)
tree0cb1a0591bfdbb8ad5e6828dcfbfe3ebd0081bc0
parentf213a276572a02fa9997c6e0375dc6de1a7333ba (diff)
downloadnode-new-0f5170339c0a504739b8de44eb8ca206a0340f94.tar.gz
remove process.{cc,h} process.exit() now exit()
the process object might return in the future but for now it is going away.
-rw-r--r--src/main.js4
-rw-r--r--src/node.cc24
-rw-r--r--src/node.h1
-rw-r--r--src/process.cc39
-rw-r--r--src/process.h11
-rw-r--r--test/test-pingpong.js2
-rw-r--r--wscript1
7 files changed, 15 insertions, 67 deletions
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<v8::String> 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<Array> 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 <v8.h>
-#include <stdlib.h>
-
-using namespace v8;
-
-static Handle<Value>
-ExitCallback (const Arguments& args)
-{
- int exit_code = 0;
- if (args.Length() > 0) exit_code = args[0]->IntegerValue();
- exit(exit_code);
- return Undefined();
-}
-
-static Handle<Value>
-OnCallback (const Arguments& args)
-{
- return Undefined();
-}
-
-void
-node::Init_process (Handle<Object> target)
-{
- HandleScope scope;
-
- Local<Object> process = ObjectTemplate::New()->NewInstance();
-
- target->Set(String::NewSymbol("process"), process);
-
- // process.exit()
- Local<FunctionTemplate> process_exit = FunctionTemplate::New(ExitCallback);
- process->Set(String::NewSymbol("exit"), process_exit->GetFunction());
-
- // process.on()
- Local<FunctionTemplate> 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 <v8.h>
-
-namespace node {
-
-void Init_process (v8::Handle<v8::Object> 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
"""