+node.cwd()+::
Returns the current working directory of the process.
-+node.kill(pid, signal)+ ::
-See kill(2). The standard POSIX signals are defined under the +node+
-namespace (+node.SIGINT+, +node.SIGUSR1+, ...).
++node.kill(pid, signal="SIGTERM")+ ::
+Send a signal to a process. +pid+ is the process id and +signal+ is the
+signal to send; for example, "SIGINT" or "SIGUSR1". See kill(2) for more
+information.
+node.compile(source, scriptOrigin)+::
Just like +eval()+ except that you can specify a +scriptOrigin+ for better
Closes the process's +stdin+ stream.
-+child.kill(signal=node.SIGTERM)+ ::
++child.kill(signal="SIGTERM")+ ::
Send a signal to the child process. If no argument is given, the process
-will be sent +node.SIGTERM+. The standard POSIX signals are defined under
-the +node+ namespace (+node.SIGINT+, +node.SIGUSR1+, ...).
+will be sent +"SIGTERM"+. See signal(7) for a list of available signals.
assert(child);
int sig = SIGTERM;
- if (args[0]->IsInt32()) sig = args[0]->Int32Value();
+
+ if (args.Length() > 0) {
+ if (args[0]->IsNumber()) {
+ sig = args[0]->Int32Value();
+ } else if (args[0]->IsString()) {
+ Local<String> signame = args[0]->ToString();
+ Local<Object> process = Context::GetCurrent()->Global();
+ Local<Object> node_obj = process->Get(String::NewSymbol("node"))->ToObject();
+
+ Local<Value> sig_v = node_obj->Get(signame);
+ if (!sig_v->IsNumber()) {
+ return ThrowException(Exception::Error(String::New("Unknown signal")));
+ }
+ sig = sig_v->Int32Value();
+ }
+ }
if (child->Kill(sig) != 0) {
return ThrowException(Exception::Error(String::New(strerror(errno))));
v8::Handle<v8::Value> Kill(const v8::Arguments& args) {
HandleScope scope;
- if (args.Length() != 2 || !args[0]->IsNumber() || !args[1]->IsInt32()) {
+ if (args.Length() < 1 || !args[0]->IsNumber()) {
return ThrowException(Exception::Error(String::New("Bad argument.")));
}
pid_t pid = args[0]->IntegerValue();
- int sig = args[1]->Int32Value();
-
+
+ int sig = SIGTERM;
+
+ if (args.Length() >= 2) {
+ if (args[1]->IsNumber()) {
+ sig = args[1]->Int32Value();
+ } else if (args[1]->IsString()) {
+ Local<String> signame = args[1]->ToString();
+ Local<Object> process = Context::GetCurrent()->Global();
+ Local<Object> node_obj = process->Get(String::NewSymbol("node"))->ToObject();
+
+ Local<Value> sig_v = node_obj->Get(signame);
+ if (!sig_v->IsNumber()) {
+ return ThrowException(Exception::Error(String::New("Unknown signal")));
+ }
+ sig = sig_v->Int32Value();
+ }
+ }
+
int r = kill(pid, sig);
if (r != 0) {
puts("running process..." + ++i);
if (i == 5) {
- node.kill(process.pid, node.SIGUSR1);
+ node.kill(process.pid, "SIGUSR1");
}
}, 1);