mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.7 KiB
66 lines
1.7 KiB
15 years ago
|
// Copyright 2009 Ryan Dahl <ry@tinyclouds.org>
|
||
|
#ifndef SRC_CHILD_PROCESS_H_
|
||
|
#define SRC_CHILD_PROCESS_H_
|
||
|
|
||
|
#include <node.h>
|
||
15 years ago
|
#include <node_events.h>
|
||
16 years ago
|
|
||
|
#include <v8.h>
|
||
|
#include <ev.h>
|
||
15 years ago
|
#include <evcom.h>
|
||
16 years ago
|
|
||
|
namespace node {
|
||
|
|
||
15 years ago
|
class ChildProcess : EventEmitter {
|
||
16 years ago
|
public:
|
||
15 years ago
|
static void Initialize(v8::Handle<v8::Object> target);
|
||
16 years ago
|
|
||
|
protected:
|
||
|
static v8::Persistent<v8::FunctionTemplate> constructor_template;
|
||
15 years ago
|
static v8::Handle<v8::Value> New(const v8::Arguments& args);
|
||
|
static v8::Handle<v8::Value> Spawn(const v8::Arguments& args);
|
||
|
static v8::Handle<v8::Value> Write(const v8::Arguments& args);
|
||
|
static v8::Handle<v8::Value> Close(const v8::Arguments& args);
|
||
|
static v8::Handle<v8::Value> Kill(const v8::Arguments& args);
|
||
|
static v8::Handle<v8::Value> PIDGetter(v8::Local<v8::String> _,
|
||
|
const v8::AccessorInfo& info);
|
||
16 years ago
|
|
||
15 years ago
|
ChildProcess();
|
||
|
~ChildProcess();
|
||
16 years ago
|
|
||
15 years ago
|
int Spawn(const char *file, char *const argv[], char *const env[]);
|
||
15 years ago
|
int Write(const char *str, size_t len);
|
||
|
int Close(void);
|
||
|
int Kill(int sig);
|
||
16 years ago
|
|
||
|
private:
|
||
15 years ago
|
static void on_read(evcom_reader *r, const void *buf, size_t len);
|
||
|
static void reader_closed(evcom_reader *r);
|
||
|
static void stdin_closed(evcom_writer *w);
|
||
|
static void OnCHLD(EV_P_ ev_child *watcher, int revents);
|
||
16 years ago
|
|
||
15 years ago
|
void MaybeShutdown(void);
|
||
|
void Shutdown(void);
|
||
16 years ago
|
|
||
15 years ago
|
evcom_reader stdout_reader_;
|
||
|
evcom_reader stderr_reader_;
|
||
|
evcom_writer stdin_writer_;
|
||
|
|
||
16 years ago
|
ev_child child_watcher_;
|
||
|
|
||
15 years ago
|
int stdout_fd_;
|
||
|
int stderr_fd_;
|
||
|
int stdin_fd_;
|
||
|
|
||
|
enum encoding stdout_encoding_;
|
||
|
enum encoding stderr_encoding_;
|
||
16 years ago
|
|
||
|
pid_t pid_;
|
||
16 years ago
|
|
||
16 years ago
|
bool got_chld_;
|
||
|
int exit_code_;
|
||
16 years ago
|
};
|
||
|
|
||
15 years ago
|
} // namespace node
|
||
|
#endif // SRC_CHILD_PROCESS_H_
|