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

Side by Side Diff: runtime/bin/vmservice/vmservice_io.dart

Issue 339193003: Avoid calling anything related to signals on Windows (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/bin/vmservice_impl.cc » ('j') | runtime/bin/vmservice_impl.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 library vmservice_io; 5 library vmservice_io;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:isolate'; 10 import 'dart:isolate';
11 import 'dart:mirrors'; 11 import 'dart:mirrors';
12 import 'dart:vmservice'; 12 import 'dart:vmservice';
13 13
14 part 'resources.dart'; 14 part 'resources.dart';
15 part 'server.dart'; 15 part 'server.dart';
16 16
17 // The TCP ip/port that the HTTP server listens on. 17 // The TCP ip/port that the HTTP server listens on.
18 int _port; 18 int _port;
19 String _ip; 19 String _ip;
20 // Should the HTTP server auto start? 20 // Should the HTTP server auto start?
21 bool _autoStart; 21 bool _autoStart;
22 22
23 bool _isWindows = false;
24
23 // HTTP servr. 25 // HTTP servr.
24 Server server; 26 Server server;
25 Future<Server> serverFuture; 27 Future<Server> serverFuture;
26 28
27 // The VM service instance. 29 // The VM service instance.
28 VMService service; 30 VMService service;
29 31
30 void _onSignal(ProcessSignal signal) { 32 void _onSignal(ProcessSignal signal) {
31 if (serverFuture != null) { 33 if (serverFuture != null) {
32 // Still waiting. 34 // Still waiting.
33 return; 35 return;
34 } 36 }
35 // Toggle HTTP server. 37 // Toggle HTTP server.
36 if (server.running) { 38 if (server.running) {
37 serverFuture = server.shutdown(true).then((_) { 39 serverFuture = server.shutdown(true).then((_) {
38 serverFuture = null; 40 serverFuture = null;
39 }); 41 });
40 } else { 42 } else {
41 serverFuture = server.startup().then((_) { 43 serverFuture = server.startup().then((_) {
42 serverFuture = null; 44 serverFuture = null;
43 }); 45 });
44 } 46 }
45 } 47 }
46 48
47 void registerSignalHandler() { 49 void registerSignalHandler() {
50 if (_isWindows) {
Anders Johnsen 2014/06/18 07:24:10 Use Platform.isWindows.
51 // Cannot register for signals on Windows.
52 return;
53 }
48 bool useSIGQUIT = true; 54 bool useSIGQUIT = true;
49 // Listen for SIGQUIT. 55 // Listen for SIGQUIT.
50 if (useSIGQUIT) { 56 if (useSIGQUIT) {
51 var io = currentMirrorSystem().findLibrary(const Symbol('dart.io')); 57 var io = currentMirrorSystem().findLibrary(const Symbol('dart.io'));
52 var c = MirrorSystem.getSymbol('_ProcessUtils', io); 58 var c = MirrorSystem.getSymbol('_ProcessUtils', io);
53 var m = MirrorSystem.getSymbol('_watchSignalInternal', io); 59 var m = MirrorSystem.getSymbol('_watchSignalInternal', io);
54 var processUtils = io.declarations[c]; 60 var processUtils = io.declarations[c];
55 processUtils.invoke(m, [ProcessSignal.SIGQUIT]).reflectee.listen(_onSignal); 61 processUtils.invoke(m, [ProcessSignal.SIGQUIT]).reflectee.listen(_onSignal);
56 } else { 62 } else {
57 ProcessSignal.SIGUSR1.watch().listen(_onSignal); 63 ProcessSignal.SIGUSR1.watch().listen(_onSignal);
58 } 64 }
59 } 65 }
60 66
61 67
62 main() { 68 main() {
63 // Get VMService. 69 // Get VMService.
64 service = new VMService(); 70 service = new VMService();
65 // Start HTTP server. 71 // Start HTTP server.
66 server = new Server(service, _ip, _port); 72 server = new Server(service, _ip, _port);
67 if (_autoStart) { 73 if (_autoStart) {
68 server.startup(); 74 server.startup();
69 } 75 }
70 76
71 try { 77 registerSignalHandler();
72 registerSignalHandler();
73 } catch (_) {
74 // Listening for signals will fail on Windows.
75 }
76 } 78 }
OLDNEW
« no previous file with comments | « no previous file | runtime/bin/vmservice_impl.cc » ('j') | runtime/bin/vmservice_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698