| Index: src/trusted/platform/nacl_process.h
|
| diff --git a/src/trusted/platform/nacl_process.h b/src/trusted/platform/nacl_process.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..24f563b91c263be137e4a1d5d2ff285a77f5882b
|
| --- /dev/null
|
| +++ b/src/trusted/platform/nacl_process.h
|
| @@ -0,0 +1,102 @@
|
| +/*
|
| + * Copyright (c) 2012 The Native Client Authors. All rights reserved.
|
| + * Use of this source code is governed by a BSD-style license that can be
|
| + * found in the LICENSE file.
|
| + */
|
| +
|
| +/*
|
| + * NaCl Service Runtime process abstraction layer.
|
| + */
|
| +
|
| +#ifndef NATIVE_CLIENT_SRC_TRUSTED_PLATFORM_NACL_PROCESS_H_
|
| +#define NATIVE_CLIENT_SRC_TRUSTED_PLATFORM_NACL_PROCESS_H_
|
| +
|
| +#include "native_client/src/include/nacl_base.h"
|
| +#include "native_client/src/include/nacl_compiler_annotations.h"
|
| +#include "native_client/src/include/portability.h"
|
| +
|
| +EXTERN_C_BEGIN
|
| +
|
| +#if NACL_LINUX || NACL_OSX || defined(__native_client__)
|
| +# include "native_client/src/trusted/platform/posix/nacl_process_types.h"
|
| +#elif NACL_WINDOWS
|
| +# include "native_client/src/trusted/platform/win/nacl_process_types.h"
|
| +#else
|
| +# error Unsupported platform
|
| +#endif
|
| +
|
| +EXTERN_C_BEGIN
|
| +
|
| +/*
|
| + * Portable process creation and management interface.
|
| + */
|
| +
|
| +/*
|
| + * Flags available for NaClProcessLaunch.
|
| + */
|
| +#define NACL_PROCESS_LAUNCH_NEW_GROUP 0x1 /* new process group */
|
| +#define NACL_PROCESS_LAUNCH_CLOSE_FDS 0x2 /* close all open fds */
|
| +
|
| +/*
|
| + * Launch a process via the command line |cmd|.
|
| + *
|
| + * Upon success, if |npp| handle is non-NULL, it will be filled in with the
|
| + * handle of the launched process.
|
| + *
|
| + * Returns 1 upon success.
|
| + */
|
| +#if NACL_WINDOWS
|
| +int NaClProcessLaunch(struct NaClProcess *npp,
|
| + char *cmd,
|
| + char *env,
|
| + int flags);
|
| +#else
|
| +int NaClProcessLaunch(struct NaClProcess *npp,
|
| + char *const *argv,
|
| + char *const *envp,
|
| + int flags);
|
| +#endif
|
| +
|
| +/*
|
| + * Attempts to kill the process identified by the process handle |npp,
|
| + * giving it the specified exit code. If |wait| is true, wait for the
|
| + * process to be actually terminated before returning.
|
| + *
|
| + * Returns 1 on success, 0 otherwise.
|
| + */
|
| +int NaClProcessKill(struct NaClProcess *npp, int exit_code, int wait);
|
| +
|
| +/*
|
| + * Return status values from NaClGetStatus.
|
| + */
|
| +#define NACL_PROCESS_STATUS_NORMAL_EXIT 0 /* zero exit status */
|
| +#define NACL_PROCESS_STATUS_ABNORMAL_EXIT 1 /* non-zero exit status */
|
| +#define NACL_PROCESS_STATUS_KILLED 2 /* SIGKILL or task manager */
|
| +#define NACL_PROCESS_STATUS_CRASHED 3 /* e.g. segmentation fault */
|
| +#define NACL_PROCESS_STATUS_STILL_RUNNING 4 /* child hasn't exited yet */
|
| +
|
| +/*
|
| + * Get the status of process identified by the process handle |npp|.
|
| + *
|
| + * Note: on Linux, this function will only return a useful result the
|
| + * first time it is called after the child exists (because it reaps the
|
| + * child and the information will no longer be available).
|
| + *
|
| + * Returns 1 on success, 0 otherwise.
|
| + */
|
| +int NaClProcessGetStatus(struct NaClProcess *npp,
|
| + int *status);
|
| +
|
| +/*
|
| + * Waits for process to exit. On POSIX systems, if the process hasn't been
|
| + * signaled then puts the exit code in |exit_code|; otherwise it's considered
|
| + * a failure. On Windows |exit_code| is always filled.
|
| + *
|
| + * Returns 1 on success, 0 otherwise.
|
| + */
|
| +int NaClProcessWaitForExitCode(struct NaClProcess *npp,
|
| + int *exit_code);
|
| +
|
| +EXTERN_C_END
|
| +
|
| +#endif /* NATIVE_CLIENT_SRC_TRUSTED_PLATFORM_NACL_PROCESS_H_ */
|
|
|