OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef BIN_PROCESS_H_ | 5 #ifndef BIN_PROCESS_H_ |
6 #define BIN_PROCESS_H_ | 6 #define BIN_PROCESS_H_ |
7 | 7 |
8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
9 #include "bin/io_buffer.h" | 9 #include "bin/io_buffer.h" |
10 #include "bin/thread.h" | 10 #include "bin/thread.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 return global_exit_code_; | 77 return global_exit_code_; |
78 } | 78 } |
79 | 79 |
80 static void SetGlobalExitCode(int exit_code) { | 80 static void SetGlobalExitCode(int exit_code) { |
81 MutexLocker ml(global_exit_code_mutex_); | 81 MutexLocker ml(global_exit_code_mutex_); |
82 global_exit_code_ = exit_code; | 82 global_exit_code_ = exit_code; |
83 } | 83 } |
84 | 84 |
85 static intptr_t CurrentProcessId(); | 85 static intptr_t CurrentProcessId(); |
86 | 86 |
87 static intptr_t SetSignalHandler(intptr_t signal); | |
88 static void ClearSignalHandler(intptr_t signal); | |
89 | |
90 static Dart_Handle GetProcessIdNativeField(Dart_Handle process, | 87 static Dart_Handle GetProcessIdNativeField(Dart_Handle process, |
91 intptr_t* pid); | 88 intptr_t* pid); |
92 static Dart_Handle SetProcessIdNativeField(Dart_Handle process, | 89 static Dart_Handle SetProcessIdNativeField(Dart_Handle process, |
93 intptr_t pid); | 90 intptr_t pid); |
94 | 91 |
95 private: | 92 private: |
96 static int global_exit_code_; | 93 static int global_exit_code_; |
97 static dart::Mutex* global_exit_code_mutex_; | 94 static dart::Mutex* global_exit_code_mutex_; |
98 | 95 |
99 DISALLOW_ALLOCATION(); | 96 DISALLOW_ALLOCATION(); |
100 DISALLOW_IMPLICIT_CONSTRUCTORS(Process); | 97 DISALLOW_IMPLICIT_CONSTRUCTORS(Process); |
101 }; | 98 }; |
102 | 99 |
103 | 100 |
104 class SignalInfo { | |
105 public: | |
106 SignalInfo(int fd, int signal, SignalInfo* prev = NULL) | |
107 : fd_(fd), | |
108 signal_(signal), | |
109 // SignalInfo is expected to be created when in a isolate. | |
110 port_(Dart_GetMainPortId()), | |
111 next_(NULL), | |
112 prev_(prev) { | |
113 if (prev_ != NULL) { | |
114 prev_->next_ = this; | |
115 } | |
116 } | |
117 | |
118 ~SignalInfo(); | |
119 | |
120 void Unlink() { | |
121 if (prev_ != NULL) { | |
122 prev_->next_ = next_; | |
123 } | |
124 if (next_ != NULL) { | |
125 next_->prev_ = prev_; | |
126 } | |
127 } | |
128 | |
129 int fd() const { return fd_; } | |
130 int signal() const { return signal_; } | |
131 Dart_Port port() const { return port_; } | |
132 SignalInfo* next() const { return next_; } | |
133 | |
134 private: | |
135 int fd_; | |
136 int signal_; | |
137 // The port_ is used to identify what isolate the signal-info belongs to. | |
138 Dart_Port port_; | |
139 SignalInfo* next_; | |
140 SignalInfo* prev_; | |
141 }; | |
142 | |
143 | |
144 // Utility class for collecting the output when running a process | 101 // Utility class for collecting the output when running a process |
145 // synchronously by using Process::Wait. This class is sub-classed in | 102 // synchronously by using Process::Wait. This class is sub-classed in |
146 // the platform specific files to implement reading into the buffers | 103 // the platform specific files to implement reading into the buffers |
147 // allocated. | 104 // allocated. |
148 class BufferListBase { | 105 class BufferListBase { |
149 protected: | 106 protected: |
150 static const intptr_t kBufferSize = 16 * 1024; | 107 static const intptr_t kBufferSize = 16 * 1024; |
151 | 108 |
152 class BufferListNode { | 109 class BufferListNode { |
153 public: | 110 public: |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 intptr_t data_size_; | 196 intptr_t data_size_; |
240 | 197 |
241 // Number of free bytes in the last node in the list. | 198 // Number of free bytes in the last node in the list. |
242 intptr_t free_size_; | 199 intptr_t free_size_; |
243 }; | 200 }; |
244 | 201 |
245 } // namespace bin | 202 } // namespace bin |
246 } // namespace dart | 203 } // namespace dart |
247 | 204 |
248 #endif // BIN_PROCESS_H_ | 205 #endif // BIN_PROCESS_H_ |
OLD | NEW |