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

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

Issue 895623002: Add support for killing a process with a given PID to dart:io (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 5 years, 10 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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);
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 String executable, 339 String executable,
340 List<String> arguments, 340 List<String> arguments,
341 {String workingDirectory, 341 {String workingDirectory,
342 Map<String, String> environment, 342 Map<String, String> environment,
343 bool includeParentEnvironment: true, 343 bool includeParentEnvironment: true,
344 bool runInShell: false, 344 bool runInShell: false,
345 Encoding stdoutEncoding: SYSTEM_ENCODING, 345 Encoding stdoutEncoding: SYSTEM_ENCODING,
346 Encoding stderrEncoding: SYSTEM_ENCODING}); 346 Encoding stderrEncoding: SYSTEM_ENCODING});
347 347
348 /** 348 /**
349 * Kills the process with id [pid].
350 *
351 * Where possible, sends the [signal] to the process with id
352 * `pid`. This includes Linux and OS X. The default signal is
353 * [ProcessSignal.SIGTERM] which will normally terminate the
354 * process.
355 *
356 * On platforms without signal support, including Windows, the call
357 * just terminates the process with id `pid` in a platform specific
358 * way, and the `signal` parameter is ignored.
359 *
360 * Returns `true` if the signal is successfully delivered to the
361 * process. Otherwise the signal could not be sent, usually meaning
362 * that the process is already dead.
363 */
364 external static bool killPid(
365 int pid, [ProcessSignal signal = ProcessSignal.SIGTERM]);
366
367 /**
349 * Returns the standard output stream of the process as a [:Stream:]. 368 * Returns the standard output stream of the process as a [:Stream:].
350 */ 369 */
351 Stream<List<int>> get stdout; 370 Stream<List<int>> get stdout;
352 371
353 /** 372 /**
354 * Returns the standard error stream of the process as a [:Stream:]. 373 * Returns the standard error stream of the process as a [:Stream:].
355 */ 374 */
356 Stream<List<int>> get stderr; 375 Stream<List<int>> get stderr;
357 376
358 /** 377 /**
359 * Returns the standard input stream of the process as an [IOSink]. 378 * Returns the standard input stream of the process as an [IOSink].
360 */ 379 */
361 IOSink get stdin; 380 IOSink get stdin;
362 381
363 /** 382 /**
364 * Returns the process id of the process. 383 * Returns the process id of the process.
365 */ 384 */
366 int get pid; 385 int get pid;
367 386
368 /** 387 /**
369 * On Linux and Mac OS, [kill] sends [signal] to the process. When the process 388 * Kills the process.
370 * terminates as a result of calling [kill], the value for [exitCode] may be a
371 * negative number corresponding to the provided [signal].
372 * 389 *
373 * On Windows, [kill] kills the process, ignoring the [signal] flag. 390 * Where possible, sends the [signal] to the process. This includes
391 * Linux and OS X. The default signal is [ProcessSignal.SIGTERM]
392 * which will normally terminate the process.
374 * 393 *
375 * Returns [:true:] if the signal is successfully sent and process is killed. 394 * On platforms without signal support, including Windows, the call
376 * Otherwise the signal could not be sent, usually meaning that the process is 395 * just terminates the process in a platform specific way, and the
377 * already dead. 396 * `signal` parameter is ignored.
397 *
398 * Returns `true` if the signal is successfully delivered to the
399 * process. Otherwise the signal could not be sent, usually meaning
400 * that the process is already dead.
378 */ 401 */
379 bool kill([ProcessSignal signal = ProcessSignal.SIGTERM]); 402 bool kill([ProcessSignal signal = ProcessSignal.SIGTERM]);
380 } 403 }
381 404
382 405
383 /** 406 /**
384 * [ProcessResult] represents the result of running a non-interactive 407 * [ProcessResult] represents the result of running a non-interactive
385 * process started with [:Process.run:]. 408 * process started with [:Process.run:].
386 */ 409 */
387 abstract class ProcessResult { 410 abstract class ProcessResult {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 final int errorCode; 544 final int errorCode;
522 545
523 const ProcessException(this.executable, this.arguments, [this.message = "", 546 const ProcessException(this.executable, this.arguments, [this.message = "",
524 this.errorCode = 0]); 547 this.errorCode = 0]);
525 String toString() { 548 String toString() {
526 var msg = (message == null) ? 'OS error code: $errorCode' : message; 549 var msg = (message == null) ? 'OS error code: $errorCode' : message;
527 var args = arguments.join(' '); 550 var args = arguments.join(' ');
528 return "ProcessException: $msg\n Command: $executable $args"; 551 return "ProcessException: $msg\n Command: $executable $args";
529 } 552 }
530 } 553 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/js_lib/io_patch.dart ('k') | tests/standalone/io/process_kill_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698