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

Unified Diff: runtime/bin/process_impl.dart

Issue 10545134: Give Process.kill an optional argument to specify which signal to send. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add USE on signal. Created 8 years, 6 months 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/process.dart ('k') | runtime/bin/process_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process_impl.dart
diff --git a/runtime/bin/process_impl.dart b/runtime/bin/process_impl.dart
index bdb5d6aca4a070ea538663d47eda8f873898091d..e2ba3e654576f856d059f2828b03165d98f590d5 100644
--- a/runtime/bin/process_impl.dart
+++ b/runtime/bin/process_impl.dart
@@ -77,7 +77,7 @@ class _Process extends Process {
_err = new _Socket._internalReadOnly(); // stderr coming from process.
_exitHandler = new _Socket._internalReadOnly();
_closed = false;
- _killed = false;
+ _ended = false;
_started = false;
_onExit = null;
// TODO(ager): Make the actual process starting really async instead of
@@ -178,6 +178,7 @@ class _Process extends Process {
}
void handleExit() {
+ _ended = true;
if (_onExit !== null) {
_onExit(exitCode(exitDataBuffer));
}
@@ -224,24 +225,27 @@ class _Process extends Process {
return _out.outputStream;
}
- void kill() {
+ void kill([ProcessSignal signal = ProcessSignal.SIGTERM]) {
+ if (signal is! ProcessSignal) {
+ throw new IllegalArgumentException(
+ "Argument 'signal' must be a ProcessSignal");
+ }
if (_closed && _pid === null) {
_reportError(new ProcessException("Process closed"));
return;
}
- if (_killed) {
+ if (_ended) {
return;
}
// TODO(ager): Make the actual kill operation asynchronous.
- if (_kill(_pid)) {
- _killed = true;
+ if (_kill(_pid, signal._signalNumber)) {
return;
}
_reportError(new ProcessException("Could not kill process"));
return;
}
- void _kill(int pid) native "Process_Kill";
+ void _kill(int pid, int signal) native "Process_Kill";
void close() {
if (_closed) {
@@ -258,7 +262,7 @@ class _Process extends Process {
if (_closed) {
throw new ProcessException("Process closed");
}
- if (_killed) {
+ if (_ended) {
throw new ProcessException("Process killed");
}
_onExit = callback;
@@ -291,7 +295,7 @@ class _Process extends Process {
Socket _exitHandler;
int _pid;
bool _closed;
- bool _killed;
+ bool _ended;
bool _started;
Function _onExit;
Function _onError;
« no previous file with comments | « runtime/bin/process.dart ('k') | runtime/bin/process_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698