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 |
87 static Dart_Handle GetProcessIdNativeField(Dart_Handle process, | 90 static Dart_Handle GetProcessIdNativeField(Dart_Handle process, |
88 intptr_t* pid); | 91 intptr_t* pid); |
89 static Dart_Handle SetProcessIdNativeField(Dart_Handle process, | 92 static Dart_Handle SetProcessIdNativeField(Dart_Handle process, |
90 intptr_t pid); | 93 intptr_t pid); |
91 | 94 |
92 private: | 95 private: |
93 static int global_exit_code_; | 96 static int global_exit_code_; |
94 static dart::Mutex* global_exit_code_mutex_; | 97 static dart::Mutex* global_exit_code_mutex_; |
95 | 98 |
96 DISALLOW_ALLOCATION(); | 99 DISALLOW_ALLOCATION(); |
97 DISALLOW_IMPLICIT_CONSTRUCTORS(Process); | 100 DISALLOW_IMPLICIT_CONSTRUCTORS(Process); |
98 }; | 101 }; |
99 | 102 |
100 | 103 |
| 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 |
101 // Utility class for collecting the output when running a process | 144 // Utility class for collecting the output when running a process |
102 // synchronously by using Process::Wait. This class is sub-classed in | 145 // synchronously by using Process::Wait. This class is sub-classed in |
103 // the platform specific files to implement reading into the buffers | 146 // the platform specific files to implement reading into the buffers |
104 // allocated. | 147 // allocated. |
105 class BufferListBase { | 148 class BufferListBase { |
106 protected: | 149 protected: |
107 static const intptr_t kBufferSize = 16 * 1024; | 150 static const intptr_t kBufferSize = 16 * 1024; |
108 | 151 |
109 class BufferListNode { | 152 class BufferListNode { |
110 public: | 153 public: |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 intptr_t data_size_; | 239 intptr_t data_size_; |
197 | 240 |
198 // Number of free bytes in the last node in the list. | 241 // Number of free bytes in the last node in the list. |
199 intptr_t free_size_; | 242 intptr_t free_size_; |
200 }; | 243 }; |
201 | 244 |
202 } // namespace bin | 245 } // namespace bin |
203 } // namespace dart | 246 } // namespace dart |
204 | 247 |
205 #endif // BIN_PROCESS_H_ | 248 #endif // BIN_PROCESS_H_ |
OLD | NEW |