summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voß <thomas.voss@rub.de>2011-12-13 10:08:09 +0100
committerThomas Voß <thomas.voss@rub.de>2011-12-13 10:08:09 +0100
commit8ace60ed7cc70589de26ec3e5e409588a0f0bd00 (patch)
treefc2e874c3b34cd2a4e09cc926ad98922226a492f
parent932bf1ec03ed9160c9784fdbb7f3a9456a5beb50 (diff)
Modified Process::Terminate and Process::Kill to reset process identifier. Adjusted documentation.
-rw-r--r--include/xorg/gtest/process.h7
-rw-r--r--src/process.cpp4
2 files changed, 9 insertions, 2 deletions
diff --git a/include/xorg/gtest/process.h b/include/xorg/gtest/process.h
index ff545e1..6b73836 100644
--- a/include/xorg/gtest/process.h
+++ b/include/xorg/gtest/process.h
@@ -71,6 +71,7 @@ class Process {
* @throws std::runtime_error on failure.
*
* @post If successful: Child process forked and program started.
+ * @post If successful: Subsequent calls to Pid() return child process pid.
*/
void Start(const std::string& program, va_list args);
@@ -85,6 +86,7 @@ class Process {
* @throws std::runtime_error on failure.
*
* @post If successful: Child process forked and program started.
+ * @post If successful: Subsequent calls to Pid() return child process pid.
*/
void Start(const std::string& program, ...);
@@ -96,7 +98,7 @@ class Process {
* @returns true if termination succeeded, false otherwise.
*
* @post Child process terminated.
- *
+ * @post Subsequent calls to Pid() return -1.
*/
bool Terminate();
@@ -108,6 +110,7 @@ class Process {
* @returns true if kill succeeded, false otherwise.
*
* @post Child process killed.
+ * @post Subsequent calls to Pid() return -1.
*/
bool Kill();
@@ -134,7 +137,7 @@ class Process {
/**
* Accesses the pid of the child process.
*
- * @returns The pid of the child process.
+ * @returns The pid of the child process or -1.
*/
pid_t Pid() const;
diff --git a/src/process.cpp b/src/process.cpp
index 303237e..2f165b7 100644
--- a/src/process.cpp
+++ b/src/process.cpp
@@ -82,8 +82,10 @@ bool xorg::testing::Process::Terminate() {
throw std::runtime_error("Child process tried to terminate itself");
} else { /* Parent */
if (kill(d_->pid, SIGTERM) < 0) {
+ d_->pid_ = -1;
return false;
}
+ d_->pid_ = -1;
}
return true;
}
@@ -96,8 +98,10 @@ bool xorg::testing::Process::Kill() {
throw std::runtime_error("Child process tried to kill itself");
} else { /* Parent */
if (kill(d_->pid, SIGKILL) < 0) {
+ d_->pid_ = -1;
return false;
}
+ d_->pid_ = -1;
}
return true;
}