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

Unified Diff: src/trusted/platform/nacl_process.h

Issue 10832400: Process abstraction layer for NaCl Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Provide consistent interface across all platforms. Created 8 years, 4 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
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..9120d1107225f8806ced9cbd31ad8de80a917ddd
--- /dev/null
+++ b/src/trusted/platform/nacl_process.h
@@ -0,0 +1,95 @@
+/*
+ * 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__)
Mark Seaborn 2012/08/24 00:22:42 Why "defined(__native_client__)" when this isn't b
+# 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 */
Mark Seaborn 2012/08/24 00:22:42 I am sceptical you really need this feature, and y
+#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.
+ */
+int NaClProcessLaunch(struct NaClProcess *npp,
+ char *const *argv,
+ char *const *envp,
+ int flags);
+
+/*
+ * Attempts to kill the process identified by the process handle |npp,
Mark Seaborn 2012/08/24 00:22:42 Missing "|": "|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_ */

Powered by Google App Engine
This is Rietveld 408576698