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

Unified Diff: runtime/bin/process.cc

Issue 10963024: Use native fields for process pid and fix bug that allowed killing (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review commetns. Created 8 years, 3 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 | « runtime/bin/process.h ('k') | runtime/bin/process_impl.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/process.cc
diff --git a/runtime/bin/process.cc b/runtime/bin/process.cc
index 3526fc6cd51f5a3d89e4430076f53f46557581cb..b786ddb0e37ffb73753ecf19296e8b02dd1bf6af 100644
--- a/runtime/bin/process.cc
+++ b/runtime/bin/process.cc
@@ -9,6 +9,9 @@
#include "include/dart_api.h"
+static const int kProcessIdNativeField = 0;
+
+
// Extract an array of C strings from a list of Dart strings.
static char** ExtractCStringList(Dart_Handle strings,
Dart_Handle status_handle,
@@ -138,7 +141,7 @@ void FUNCTION_NAME(Process_Start)(Dart_NativeArguments args) {
Socket::SetSocketIdNativeField(out_handle, out);
Socket::SetSocketIdNativeField(err_handle, err);
Socket::SetSocketIdNativeField(exit_handle, exit_event);
- DartUtils::SetIntegerField(process, "_pid", pid);
+ Process::SetProcessIdNativeField(process, pid);
} else {
DartUtils::SetIntegerField(
status_handle, "_errorCode", error_code);
@@ -154,9 +157,23 @@ void FUNCTION_NAME(Process_Start)(Dart_NativeArguments args) {
void FUNCTION_NAME(Process_Kill)(Dart_NativeArguments args) {
Dart_EnterScope();
- intptr_t pid = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 1));
+ Dart_Handle process = Dart_GetNativeArgument(args, 1);
+ intptr_t pid = -1;
+ Process::GetProcessIdNativeField(process, &pid);
int signal = DartUtils::GetIntegerValue(Dart_GetNativeArgument(args, 2));
bool success = Process::Kill(pid, signal);
Dart_SetReturnValue(args, Dart_NewBoolean(success));
Dart_ExitScope();
}
+
+
+Dart_Handle Process::GetProcessIdNativeField(Dart_Handle process,
+ intptr_t* pid) {
+ return Dart_GetNativeInstanceField(process, kProcessIdNativeField, pid);
+}
+
+
+Dart_Handle Process::SetProcessIdNativeField(Dart_Handle process,
+ intptr_t pid) {
+ return Dart_SetNativeInstanceField(process, kProcessIdNativeField, pid);
+}
« no previous file with comments | « runtime/bin/process.h ('k') | runtime/bin/process_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698