forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
node_child_process.h
65 lines (49 loc) · 1.65 KB
/
node_child_process.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright 2009 Ryan Dahl <[email protected]>
#ifndef SRC_CHILD_PROCESS_H_
#define SRC_CHILD_PROCESS_H_
#include <node.h>
#include <node_events.h>
#include <v8.h>
#include <ev.h>
#include <evcom.h>
namespace node {
class ChildProcess : EventEmitter {
public:
static void Initialize(v8::Handle<v8::Object> target);
protected:
static v8::Persistent<v8::FunctionTemplate> constructor_template;
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);
ChildProcess();
~ChildProcess();
int Spawn(const char *file, char *const argv[], char *const env[]);
int Write(const char *str, size_t len);
int Close(void);
int Kill(int sig);
private:
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);
void MaybeShutdown(void);
void Shutdown(void);
evcom_reader stdout_reader_;
evcom_reader stderr_reader_;
evcom_writer stdin_writer_;
ev_child child_watcher_;
int stdout_fd_;
int stderr_fd_;
int stdin_fd_;
enum encoding stdout_encoding_;
enum encoding stderr_encoding_;
pid_t pid_;
bool got_chld_;
int exit_code_;
};
} // namespace node
#endif // SRC_CHILD_PROCESS_H_