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

Unified Diff: runtime/bin/process_patch.dart

Issue 14322011: Add access to process id for both current process and processes started (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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
Index: runtime/bin/process_patch.dart
diff --git a/runtime/bin/process_patch.dart b/runtime/bin/process_patch.dart
index ae87f4e0e4edceed464cb69bb14153c7be7c7ff2..8de3d9b2fda8a05fd42f7530743e6dd1b642958a 100644
--- a/runtime/bin/process_patch.dart
+++ b/runtime/bin/process_patch.dart
@@ -34,6 +34,7 @@ patch class _ProcessUtils {
/* patch */ static _exit(int status) native "Process_Exit";
/* patch */ static _setExitCode(int status) native "Process_SetExitCode";
/* patch */ static _sleep(int millis) native "Process_Sleep";
+ /* patch */ static _pid(Process process) native "Process_Pid";
}
@@ -247,6 +248,8 @@ class _ProcessImpl extends NativeFieldWrapperClass1 implements Process {
bool _kill(Process p, int signal) native "Process_Kill";
+ int get pid => _ProcessUtils._pid(this);
+
String _path;
List<String> _arguments;
String _workingDirectory;
@@ -291,6 +294,8 @@ Future<ProcessResult> _runNonInteractiveProcess(String path,
// Start the underlying process.
return Process.start(path, arguments, options).then((Process p) {
+ int pid = p.pid;
+
// Make sure the process stdin is closed.
p.stdin.close();
@@ -314,7 +319,8 @@ Future<ProcessResult> _runNonInteractiveProcess(String path,
});
return Future.wait([p.exitCode, stdout, stderr]).then((result) {
- return new _ProcessResult(result[0],
+ return new _ProcessResult(pid,
+ result[0],
result[1].toString(),
result[2].toString());
});
@@ -323,10 +329,12 @@ Future<ProcessResult> _runNonInteractiveProcess(String path,
class _ProcessResult implements ProcessResult {
- const _ProcessResult(int this.exitCode,
+ const _ProcessResult(int this.pid,
Anders Johnsen 2013/04/17 09:13:06 I'm not sure it makes sense to get the pid of an a
Søren Gjesse 2013/04/17 10:15:12 Not sure either, but sometimes processes write fil
+ int this.exitCode,
String this.stdout,
String this.stderr);
+ final int pid;
final int exitCode;
final String stdout;
final String stderr;
« no previous file with comments | « runtime/bin/process.cc ('k') | sdk/lib/io/process.dart » ('j') | sdk/lib/io/process.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698