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

Unified Diff: sdk/lib/_internal/pub/lib/src/executable.dart

Issue 1044033003: Forward signals to pub run processes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 5 years, 9 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 | « no previous file | sdk/lib/_internal/pub/pub.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/pub/lib/src/executable.dart
diff --git a/sdk/lib/_internal/pub/lib/src/executable.dart b/sdk/lib/_internal/pub/lib/src/executable.dart
index 1c22b801339ed241c6455c2a2d57672bd501253c..8d9d67f63bb791498ef5280e98a64d14d90ec7fc 100644
--- a/sdk/lib/_internal/pub/lib/src/executable.dart
+++ b/sdk/lib/_internal/pub/lib/src/executable.dart
@@ -18,6 +18,18 @@ import 'io.dart';
import 'log.dart' as log;
import 'utils.dart';
+/// All signals that can be caught by a Dart process.
+final _catchableSignals = Platform.isWindows
+ ? [ProcessSignal.SIGHUP, ProcessSignal.SIGINT]
+ : [
+ ProcessSignal.SIGHUP,
+ ProcessSignal.SIGINT,
+ ProcessSignal.SIGTERM,
+ ProcessSignal.SIGUSR1,
+ ProcessSignal.SIGUSR2,
+ ProcessSignal.SIGWINCH,
+ ];
+
/// Runs [executable] from [package] reachable from [entrypoint].
///
/// The executable string is a relative Dart file path using native path
@@ -132,6 +144,9 @@ Future<int> runExecutable(Entrypoint entrypoint, String package,
vmArgs.addAll(args);
var process = await Process.start(Platform.executable, vmArgs);
+
+ _ignoreSignals();
+
// Note: we're not using process.std___.pipe(std___) here because
// that prevents pub from also writing to the output streams.
process.stderr.listen(stderr.add);
@@ -176,6 +191,8 @@ Future<int> runSnapshot(String path, Iterable<String> args, {recompile(),
runProcess(input) async {
var process = await Process.start(Platform.executable, vmArgs);
+ _ignoreSignals();
+
// Note: we're not using process.std___.pipe(std___) here because
// that prevents pub from also writing to the output streams.
process.stderr.listen(stderr.add);
@@ -194,6 +211,17 @@ Future<int> runSnapshot(String path, Iterable<String> args, {recompile(),
return runProcess(stdin2);
}
+/// Ignore all catchable signals.
+///
+/// All signals are automatically sent to all processes in the tree, so this
+/// makes the child process responsible for dealing with the signals as it sees
+/// fit.
+void _ignoreSignals() {
+ for (var signal in _catchableSignals) {
+ signal.watch().listen((_) => log.fine("Ignoring $signal in pub."));
+ }
+}
+
/// Runs the executable snapshot at [snapshotPath].
Future<int> _runCachedExecutable(Entrypoint entrypoint, String snapshotPath,
List<String> args) {
« no previous file with comments | « no previous file | sdk/lib/_internal/pub/pub.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698