| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #ifndef BIN_PROCESS_H_ | 5 #ifndef BIN_PROCESS_H_ |
| 6 #define BIN_PROCESS_H_ | 6 #define BIN_PROCESS_H_ |
| 7 | 7 |
| 8 #include "bin/builtin.h" | 8 #include "bin/builtin.h" |
| 9 #include "bin/thread.h" |
| 9 #include "platform/globals.h" | 10 #include "platform/globals.h" |
| 10 | 11 |
| 11 | 12 |
| 12 class Process { | 13 class Process { |
| 13 public: | 14 public: |
| 14 // Start a new process providing access to stdin, stdout, stderr and | 15 // Start a new process providing access to stdin, stdout, stderr and |
| 15 // process exit streams. | 16 // process exit streams. |
| 16 static int Start(const char* path, | 17 static int Start(const char* path, |
| 17 char* arguments[], | 18 char* arguments[], |
| 18 intptr_t arguments_length, | 19 intptr_t arguments_length, |
| 19 const char* working_directory, | 20 const char* working_directory, |
| 20 char* environment[], | 21 char* environment[], |
| 21 intptr_t environment_length, | 22 intptr_t environment_length, |
| 22 intptr_t* in, | 23 intptr_t* in, |
| 23 intptr_t* out, | 24 intptr_t* out, |
| 24 intptr_t* err, | 25 intptr_t* err, |
| 25 intptr_t* id, | 26 intptr_t* id, |
| 26 intptr_t* exit_handler, | 27 intptr_t* exit_handler, |
| 27 char** os_error_message); | 28 char** os_error_message); |
| 28 | 29 |
| 29 // Kill a process with a given pid. | 30 // Kill a process with a given pid. |
| 30 static bool Kill(intptr_t id, int signal); | 31 static bool Kill(intptr_t id, int signal); |
| 31 | 32 |
| 32 // Terminate the exit code handler thread. Does not return before | 33 // Terminate the exit code handler thread. Does not return before |
| 33 // the thread has terminated. | 34 // the thread has terminated. |
| 34 static void TerminateExitCodeHandler(); | 35 static void TerminateExitCodeHandler(); |
| 35 | 36 |
| 37 static int GlobalExitCode() { |
| 38 MutexLocker ml(&global_exit_code_mutex_); |
| 39 return global_exit_code_; |
| 40 } |
| 41 |
| 42 static void SetGlobalExitCode(int exit_code) { |
| 43 MutexLocker ml(&global_exit_code_mutex_); |
| 44 global_exit_code_ = exit_code; |
| 45 } |
| 46 |
| 36 static intptr_t CurrentProcessId(); | 47 static intptr_t CurrentProcessId(); |
| 37 | 48 |
| 38 static Dart_Handle GetProcessIdNativeField(Dart_Handle process, | 49 static Dart_Handle GetProcessIdNativeField(Dart_Handle process, |
| 39 intptr_t* pid); | 50 intptr_t* pid); |
| 40 static Dart_Handle SetProcessIdNativeField(Dart_Handle process, | 51 static Dart_Handle SetProcessIdNativeField(Dart_Handle process, |
| 41 intptr_t pid); | 52 intptr_t pid); |
| 42 | 53 |
| 54 private: |
| 55 static int global_exit_code_; |
| 56 static dart::Mutex global_exit_code_mutex_; |
| 57 |
| 43 DISALLOW_ALLOCATION(); | 58 DISALLOW_ALLOCATION(); |
| 44 DISALLOW_IMPLICIT_CONSTRUCTORS(Process); | 59 DISALLOW_IMPLICIT_CONSTRUCTORS(Process); |
| 45 }; | 60 }; |
| 46 | 61 |
| 47 #endif // BIN_PROCESS_H_ | 62 #endif // BIN_PROCESS_H_ |
| OLD | NEW |