Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. | |
| 3 * Use of this source code is governed by a BSD-style license that can be | |
| 4 * found in the LICENSE file. | |
| 5 */ | |
| 6 | |
| 7 /* | |
| 8 * NaCl Service Runtime process abstraction layer. | |
| 9 */ | |
| 10 | |
| 11 #ifndef NATIVE_CLIENT_SRC_TRUSTED_PLATFORM_NACL_PROCESS_H_ | |
| 12 #define NATIVE_CLIENT_SRC_TRUSTED_PLATFORM_NACL_PROCESS_H_ | |
| 13 | |
| 14 #include "native_client/src/include/nacl_base.h" | |
| 15 #include "native_client/src/include/nacl_compiler_annotations.h" | |
| 16 #include "native_client/src/include/portability.h" | |
| 17 | |
| 18 EXTERN_C_BEGIN | |
| 19 | |
| 20 #if NACL_LINUX || NACL_OSX || defined(__native_client__) | |
|
Mark Seaborn
2012/08/24 00:22:42
Why "defined(__native_client__)" when this isn't b
| |
| 21 # include "native_client/src/trusted/platform/posix/nacl_process_types.h" | |
| 22 #elif NACL_WINDOWS | |
| 23 # include "native_client/src/trusted/platform/win/nacl_process_types.h" | |
| 24 #else | |
| 25 # error Unsupported platform | |
| 26 #endif | |
| 27 | |
| 28 EXTERN_C_BEGIN | |
| 29 | |
| 30 /* | |
| 31 * Portable process creation and management interface. | |
| 32 */ | |
| 33 | |
| 34 /* | |
| 35 * Flags available for NaClProcessLaunch. | |
| 36 */ | |
| 37 #define NACL_PROCESS_LAUNCH_NEW_GROUP 0x1 /* new process group */ | |
|
Mark Seaborn
2012/08/24 00:22:42
I am sceptical you really need this feature, and y
| |
| 38 #define NACL_PROCESS_LAUNCH_CLOSE_FDS 0x2 /* close all open fds */ | |
| 39 | |
| 40 /* | |
| 41 * Launch a process via the command line |cmd|. | |
| 42 * | |
| 43 * Upon success, if |npp| handle is non-NULL, it will be filled in with the | |
| 44 * handle of the launched process. | |
| 45 * | |
| 46 * Returns 1 upon success. | |
| 47 */ | |
| 48 int NaClProcessLaunch(struct NaClProcess *npp, | |
| 49 char *const *argv, | |
| 50 char *const *envp, | |
| 51 int flags); | |
| 52 | |
| 53 /* | |
| 54 * Attempts to kill the process identified by the process handle |npp, | |
|
Mark Seaborn
2012/08/24 00:22:42
Missing "|": "|npp|"
| |
| 55 * giving it the specified exit code. If |wait| is true, wait for the | |
| 56 * process to be actually terminated before returning. | |
| 57 * | |
| 58 * Returns 1 on success, 0 otherwise. | |
| 59 */ | |
| 60 int NaClProcessKill(struct NaClProcess *npp, int exit_code, int wait); | |
| 61 | |
| 62 /* | |
| 63 * Return status values from NaClGetStatus. | |
| 64 */ | |
| 65 #define NACL_PROCESS_STATUS_NORMAL_EXIT 0 /* zero exit status */ | |
| 66 #define NACL_PROCESS_STATUS_ABNORMAL_EXIT 1 /* non-zero exit status */ | |
| 67 #define NACL_PROCESS_STATUS_KILLED 2 /* SIGKILL or task manager */ | |
| 68 #define NACL_PROCESS_STATUS_CRASHED 3 /* e.g. segmentation fault */ | |
| 69 #define NACL_PROCESS_STATUS_STILL_RUNNING 4 /* child hasn't exited yet */ | |
| 70 | |
| 71 /* | |
| 72 * Get the status of process identified by the process handle |npp|. | |
| 73 * | |
| 74 * Note: on Linux, this function will only return a useful result the | |
| 75 * first time it is called after the child exists (because it reaps the | |
| 76 * child and the information will no longer be available). | |
| 77 * | |
| 78 * Returns 1 on success, 0 otherwise. | |
| 79 */ | |
| 80 int NaClProcessGetStatus(struct NaClProcess *npp, | |
| 81 int *status); | |
| 82 | |
| 83 /* | |
| 84 * Waits for process to exit. On POSIX systems, if the process hasn't been | |
| 85 * signaled then puts the exit code in |exit_code|; otherwise it's considered | |
| 86 * a failure. On Windows |exit_code| is always filled. | |
| 87 * | |
| 88 * Returns 1 on success, 0 otherwise. | |
| 89 */ | |
| 90 int NaClProcessWaitForExitCode(struct NaClProcess *npp, | |
| 91 int *exit_code); | |
| 92 | |
| 93 EXTERN_C_END | |
| 94 | |
| 95 #endif /* NATIVE_CLIENT_SRC_TRUSTED_PLATFORM_NACL_PROCESS_H_ */ | |
| OLD | NEW |