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

Side by Side Diff: sdk/lib/io/process.dart

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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/lib/io_patch.dart ('k') | tests/standalone/io/signals_test.dart » ('j') | no next file with comments »
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 part of dart.io; 5 part of dart.io;
6 6
7 // TODO(ager): The only reason for this class is that we 7 // TODO(ager): The only reason for this class is that we
8 // cannot patch a top-level at this point. 8 // cannot patch a top-level at this point.
9 class _ProcessUtils { 9 class _ProcessUtils {
10 external static void _exit(int status); 10 external static void _exit(int status);
11 external static void _setExitCode(int status); 11 external static void _setExitCode(int status);
12 external static void _sleep(int millis); 12 external static void _sleep(int millis);
13 external static int _pid(Process process); 13 external static int _pid(Process process);
14 external static Stream<ProcessSignal> _watchSignal(ProcessSignal signal);
14 } 15 }
15 16
16 /** 17 /**
17 * Exit the Dart VM process immediately with the given exit code. 18 * Exit the Dart VM process immediately with the given exit code.
18 * 19 *
19 * This does not wait for any asynchronous operations to terminate. Using 20 * This does not wait for any asynchronous operations to terminate. Using
20 * [exit] is therefore very likely to lose data. 21 * [exit] is therefore very likely to lose data.
21 * 22 *
22 * The handling of exit codes is platform specific. 23 * The handling of exit codes is platform specific.
23 * 24 *
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 */ 304 */
304 int get pid; 305 int get pid;
305 } 306 }
306 307
307 308
308 /** 309 /**
309 * On Posix systems, [ProcessSignal] is used to send a specific signal 310 * On Posix systems, [ProcessSignal] is used to send a specific signal
310 * to a child process, see [:Process.kill:]. 311 * to a child process, see [:Process.kill:].
311 */ 312 */
312 class ProcessSignal { 313 class ProcessSignal {
313 static const ProcessSignal SIGHUP = const ProcessSignal._signal(1); 314 static const ProcessSignal SIGHUP = const ProcessSignal._(1, "SIGHUP");
314 static const ProcessSignal SIGINT = const ProcessSignal._signal(2); 315 static const ProcessSignal SIGINT = const ProcessSignal._(2, "SIGINT");
315 static const ProcessSignal SIGQUIT = const ProcessSignal._signal(3); 316 static const ProcessSignal SIGQUIT = const ProcessSignal._(3, "SIGQUIT");
316 static const ProcessSignal SIGILL = const ProcessSignal._signal(4); 317 static const ProcessSignal SIGILL = const ProcessSignal._(4, "SIGILL");
317 static const ProcessSignal SIGTRAP = const ProcessSignal._signal(5); 318 static const ProcessSignal SIGTRAP = const ProcessSignal._(5, "SIGTRAP");
318 static const ProcessSignal SIGABRT = const ProcessSignal._signal(6); 319 static const ProcessSignal SIGABRT = const ProcessSignal._(6, "SIGABRT");
319 static const ProcessSignal SIGBUS = const ProcessSignal._signal(7); 320 static const ProcessSignal SIGBUS = const ProcessSignal._(7, "SIGBUS");
320 static const ProcessSignal SIGFPE = const ProcessSignal._signal(8); 321 static const ProcessSignal SIGFPE = const ProcessSignal._(8, "SIGFPE");
321 static const ProcessSignal SIGKILL = const ProcessSignal._signal(9); 322 static const ProcessSignal SIGKILL = const ProcessSignal._(9, "SIGKILL");
322 static const ProcessSignal SIGUSR1 = const ProcessSignal._signal(10); 323 static const ProcessSignal SIGUSR1 = const ProcessSignal._(10, "SIGUSR1");
323 static const ProcessSignal SIGSEGV = const ProcessSignal._signal(11); 324 static const ProcessSignal SIGSEGV = const ProcessSignal._(11, "SIGSEGV");
324 static const ProcessSignal SIGUSR2 = const ProcessSignal._signal(12); 325 static const ProcessSignal SIGUSR2 = const ProcessSignal._(12, "SIGUSR2");
325 static const ProcessSignal SIGPIPE = const ProcessSignal._signal(13); 326 static const ProcessSignal SIGPIPE = const ProcessSignal._(13, "SIGPIPE");
326 static const ProcessSignal SIGALRM = const ProcessSignal._signal(14); 327 static const ProcessSignal SIGALRM = const ProcessSignal._(14, "SIGALRM");
327 static const ProcessSignal SIGTERM = const ProcessSignal._signal(15); 328 static const ProcessSignal SIGTERM = const ProcessSignal._(15, "SIGTERM");
328 static const ProcessSignal SIGCHLD = const ProcessSignal._signal(17); 329 static const ProcessSignal SIGCHLD = const ProcessSignal._(17, "SIGCHLD");
329 static const ProcessSignal SIGCONT = const ProcessSignal._signal(18); 330 static const ProcessSignal SIGCONT = const ProcessSignal._(18, "SIGCONT");
330 static const ProcessSignal SIGSTOP = const ProcessSignal._signal(19); 331 static const ProcessSignal SIGSTOP = const ProcessSignal._(19, "SIGSTOP");
331 static const ProcessSignal SIGTSTP = const ProcessSignal._signal(20); 332 static const ProcessSignal SIGTSTP = const ProcessSignal._(20, "SIGTSTP");
332 static const ProcessSignal SIGTTIN = const ProcessSignal._signal(21); 333 static const ProcessSignal SIGTTIN = const ProcessSignal._(21, "SIGTTIN");
333 static const ProcessSignal SIGTTOU = const ProcessSignal._signal(22); 334 static const ProcessSignal SIGTTOU = const ProcessSignal._(22, "SIGTTOU");
334 static const ProcessSignal SIGURG = const ProcessSignal._signal(23); 335 static const ProcessSignal SIGURG = const ProcessSignal._(23, "SIGURG");
335 static const ProcessSignal SIGXCPU = const ProcessSignal._signal(24); 336 static const ProcessSignal SIGXCPU = const ProcessSignal._(24, "SIGXCPU");
336 static const ProcessSignal SIGXFSZ = const ProcessSignal._signal(25); 337 static const ProcessSignal SIGXFSZ = const ProcessSignal._(25, "SIGXFSZ");
337 static const ProcessSignal SIGVTALRM = const ProcessSignal._signal(26); 338 static const ProcessSignal SIGVTALRM = const ProcessSignal._(26, "SIGVTALRM");
338 static const ProcessSignal SIGPROF = const ProcessSignal._signal(27); 339 static const ProcessSignal SIGPROF = const ProcessSignal._(27, "SIGPROF");
339 static const ProcessSignal SIGPOLL = const ProcessSignal._signal(29); 340 static const ProcessSignal SIGWINCH = const ProcessSignal._(28, "SIGWINCH");
340 static const ProcessSignal SIGSYS = const ProcessSignal._signal(31); 341 static const ProcessSignal SIGPOLL = const ProcessSignal._(29, "SIGPOLL");
342 static const ProcessSignal SIGSYS = const ProcessSignal._(31, "SIGSYS");
341 343
342 const ProcessSignal._signal(int this._signalNumber);
343 final int _signalNumber; 344 final int _signalNumber;
345 final String _name;
346
347 const ProcessSignal._(this._signalNumber, this._name);
348
349 String toString() => _name;
350
351 Stream<ProcessSignal> watch() => _ProcessUtils._watchSignal(this);
344 } 352 }
345 353
346 354
355 class SignalException implements IOException {
356 final String message;
357 final osError;
358
359 const SignalException(String this.message, [this.osError = null]);
360
361 String toString() {
362 var msg = "";
363 if (osError != null) {
364 msg = ", osError: $osError";
365 }
366 return "SignalException: $message$msg";
367 }
368 }
369
370
347 class ProcessException implements IOException { 371 class ProcessException implements IOException {
348 const ProcessException(String this.executable, 372 const ProcessException(String this.executable,
349 List<String> this.arguments, 373 List<String> this.arguments,
350 [String this.message = "", 374 [String this.message = "",
351 int this.errorCode = 0]); 375 int this.errorCode = 0]);
352 String toString() { 376 String toString() {
353 var msg = (message == null) ? 'OS error code: $errorCode' : message; 377 var msg = (message == null) ? 'OS error code: $errorCode' : message;
354 var args = arguments.join(' '); 378 var args = arguments.join(' ');
355 return "ProcessException: $msg\n Command: $executable $args"; 379 return "ProcessException: $msg\n Command: $executable $args";
356 } 380 }
(...skipping 11 matching lines...) Expand all
368 /** 392 /**
369 * Contains the system message for the process exception if any. 393 * Contains the system message for the process exception if any.
370 */ 394 */
371 final String message; 395 final String message;
372 396
373 /** 397 /**
374 * Contains the OS error code for the process exception if any. 398 * Contains the OS error code for the process exception if any.
375 */ 399 */
376 final int errorCode; 400 final int errorCode;
377 } 401 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/lib/io_patch.dart ('k') | tests/standalone/io/signals_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698