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

Unified Diff: runtime/bin/process.h

Issue 119093007: Signal handling, take 2. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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..adda36a482df209db749dcee60538d91d276377b 100644
--- a/runtime/bin/process.h
+++ b/runtime/bin/process.h
@@ -41,6 +41,41 @@ class ProcessResult {
};
+// To be kept in sync with ProcessSignal consts in sdk/lib/io/process.dart
+// Note that this map is as on Linux.
+enum ProcessSignals {
+ kSighup = 1,
+ kSigint = 2,
+ kSigquit = 3,
+ kSigill = 4,
+ kSigtrap = 5,
+ kSigabrt = 6,
+ kSigbus = 7,
+ kSigfpe = 8,
+ kSigkill = 9,
+ kSigusr1 = 10,
+ kSigsegv = 11,
+ kSigusr2 = 12,
+ kSigpipe = 13,
+ kSigalrm = 14,
+ kSigterm = 15,
+ kSigchld = 17,
+ kSigcont = 18,
+ kSigstop = 19,
+ kSigtstp = 20,
+ kSigttin = 21,
+ kSigttou = 22,
+ kSigurg = 23,
+ kSigxcpu = 24,
+ kSigxfsz = 25,
+ kSigvtalrm = 26,
+ kSigprof = 27,
+ kSigwinch = 28,
+ kSigpoll = 29,
+ kSigsys = 31
+};
+
+
class Process {
public:
// Start a new process providing access to stdin, stdout, stderr and
@@ -84,6 +119,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 +136,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