summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPeter Hutterer <peter.hutterer@who-t.net>2012-08-10 08:21:53 +1000
committerPeter Hutterer <peter.hutterer@who-t.net>2012-08-17 10:19:41 +1000
commit81fe80e8c075a9435dfb60056b9ff5a9072588f0 (patch)
tree3e6611e9e50defc9b80073153d08a30c8ea77b1f /include
parent43bdab62ed12dba83add8caeafb09b73491c9e26 (diff)
process: add state enum and GetState()
Add a set of basic states to Process to allow callers to keep track of which state a process is in (as seen from the library). This simplifies code that needs to happen on certain conditions only, e.g. log file cleanup is only needed if the process was previously started. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net> Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
Diffstat (limited to 'include')
-rw-r--r--include/xorg/gtest/xorg-gtest-process.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/xorg/gtest/xorg-gtest-process.h b/include/xorg/gtest/xorg-gtest-process.h
index b4ac0d9..f1fc0ec 100644
--- a/include/xorg/gtest/xorg-gtest-process.h
+++ b/include/xorg/gtest/xorg-gtest-process.h
@@ -64,6 +64,22 @@ namespace testing {
*/
class Process {
public:
+ /**
+ * Describes the state of a process as seen by this library. This state
+ * changes some behaviors inside the library, most notably:
+ * * A process in state ERROR or NONE will fail to Kill() or Terminate()
+ * * A process in state FINISHED_SUCCESS or FINISHED_FAILURE will always
+ * succeed to Kill() or Terminate()
+ */
+ enum State {
+ ERROR, /**< An error has occured, state is now unknown */
+ NONE, /**< The process has not been started yet */
+ RUNNING, /**< The process has been started */
+ FINISHED_SUCCESS, /**< The process finished with an exit code of 0 */
+ FINISHED_FAILURE, /**< The process finished with a non-zero exit code */
+ TERMINATED, /**< The process was successfully terminated by this library */
+ };
+
/**
* Helper function to adjust the environment of the current process.
*
@@ -183,6 +199,13 @@ class Process {
*/
pid_t Pid() const;
+ /**
+ * Return the state of the process.
+ *
+ * @return The current state of the process
+ */
+ enum Process::State GetState();
+
private:
struct Private;
std::auto_ptr<Private> d_;