Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Unified Diff: runtime/bin/process.h

Issue 108003009: Signal handling. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Nicer API and Android+Mac versions. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/io_natives.cc ('k') | runtime/bin/process.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process.h
diff --git a/runtime/bin/process.h b/runtime/bin/process.h
index 02a9ecc845372bf46fa04c0ce5cb2f2c32e5d4a1..4709770304e1c1b012b50c4a328760f966b6368f 100644
--- a/runtime/bin/process.h
+++ b/runtime/bin/process.h
@@ -84,6 +84,9 @@ class Process {
static intptr_t CurrentProcessId();
+ static intptr_t SetSignalHandler(intptr_t signal);
+ static void ClearSignalHandler(intptr_t signal);
+
static Dart_Handle GetProcessIdNativeField(Dart_Handle process,
intptr_t* pid);
static Dart_Handle SetProcessIdNativeField(Dart_Handle process,
@@ -98,6 +101,46 @@ class Process {
};
+class SignalInfo {
+ public:
+ SignalInfo(int fd, int signal, SignalInfo* prev = NULL)
+ : fd_(fd),
+ signal_(signal),
+ // SignalInfo is expected to be created when in a isolate.
+ port_(Dart_GetMainPortId()),
+ next_(NULL),
+ prev_(prev) {
+ if (prev_ != NULL) {
+ prev_->next_ = this;
+ }
+ }
+
+ ~SignalInfo();
+
+ void Unlink() {
+ if (prev_ != NULL) {
+ prev_->next_ = next_;
+ }
+ if (next_ != NULL) {
+ next_->prev_ = prev_;
+ }
+ }
+
+ int fd() const { return fd_; }
+ int signal() const { return signal_; }
+ Dart_Port port() const { return port_; }
+ SignalInfo* next() const { return next_; }
+
+ private:
+ int fd_;
+ int signal_;
+ // The port_ is used to identify what isolate the signal-info belongs to.
+ Dart_Port port_;
+ SignalInfo* next_;
+ SignalInfo* prev_;
+};
+
+
// Utility class for collecting the output when running a process
// synchronously by using Process::Wait. This class is sub-classed in
// the platform specific files to implement reading into the buffers
« no previous file with comments | « runtime/bin/io_natives.cc ('k') | runtime/bin/process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698