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

Side by Side Diff: runtime/bin/process.cc

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
« no previous file with comments | « runtime/bin/io_natives.cc ('k') | runtime/bin/process_patch.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 #include "bin/dartutils.h" 5 #include "bin/dartutils.h"
6 #include "bin/io_buffer.h" 6 #include "bin/io_buffer.h"
7 #include "bin/platform.h" 7 #include "bin/platform.h"
8 #include "bin/process.h" 8 #include "bin/process.h"
9 #include "bin/socket.h" 9 #include "bin/socket.h"
10 #include "bin/utils.h" 10 #include "bin/utils.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 Dart_SetReturnValue(args, list); 194 Dart_SetReturnValue(args, list);
195 } else { 195 } else {
196 Dart_Handle error = DartUtils::NewDartOSError(); 196 Dart_Handle error = DartUtils::NewDartOSError();
197 Process::Kill(pid, 9); 197 Process::Kill(pid, 9);
198 if (Dart_IsError(error)) Dart_PropagateError(error); 198 if (Dart_IsError(error)) Dart_PropagateError(error);
199 Dart_ThrowException(error); 199 Dart_ThrowException(error);
200 } 200 }
201 } 201 }
202 202
203 203
204 void FUNCTION_NAME(Process_Kill)(Dart_NativeArguments args) { 204 void FUNCTION_NAME(Process_KillPid)(Dart_NativeArguments args) {
205 Dart_Handle process = Dart_GetNativeArgument(args, 1); 205 intptr_t pid = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 0));
206 intptr_t pid = -1; 206 intptr_t signal = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 1));
207 Process::GetProcessIdNativeField(process, &pid);
208 intptr_t signal = DartUtils::GetIntptrValue(Dart_GetNativeArgument(args, 2));
209 bool success = Process::Kill(pid, signal); 207 bool success = Process::Kill(pid, signal);
210 Dart_SetReturnValue(args, Dart_NewBoolean(success)); 208 Dart_SetReturnValue(args, Dart_NewBoolean(success));
211 } 209 }
212 210
213 211
214 void FUNCTION_NAME(Process_Exit)(Dart_NativeArguments args) { 212 void FUNCTION_NAME(Process_Exit)(Dart_NativeArguments args) {
215 int64_t status = 0; 213 int64_t status = 0;
216 // Ignore result if passing invalid argument and just exit 0. 214 // Ignore result if passing invalid argument and just exit 0.
217 DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 0), &status); 215 DartUtils::GetInt64Value(Dart_GetNativeArgument(args, 0), &status);
218 Dart_ExitIsolate(); 216 Dart_ExitIsolate();
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 int external_length = strlen(system_string); 309 int external_length = strlen(system_string);
312 uint8_t* buffer = NULL; 310 uint8_t* buffer = NULL;
313 Dart_Handle external_array = IOBuffer::Allocate(external_length, &buffer); 311 Dart_Handle external_array = IOBuffer::Allocate(external_length, &buffer);
314 memmove(buffer, system_string, external_length); 312 memmove(buffer, system_string, external_length);
315 if (utf8 != system_string) free(const_cast<char*>(system_string)); 313 if (utf8 != system_string) free(const_cast<char*>(system_string));
316 Dart_SetReturnValue(args, external_array); 314 Dart_SetReturnValue(args, external_array);
317 } 315 }
318 316
319 } // namespace bin 317 } // namespace bin
320 } // namespace dart 318 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/io_natives.cc ('k') | runtime/bin/process_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698