[PATCH xorg-gtest 6/7] process: if the wait fails because the child is still running, reset errno
Peter Hutterer
peter.hutterer at who-t.net
Thu Dec 13 17:17:39 PST 2012
Prevent callers from getting odd errors if they notice the wait fails
because the child is still running and errno is still on whatever it was
before.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/process.cpp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/process.cpp b/src/process.cpp
index af8b0f8..9580569 100644
--- a/src/process.cpp
+++ b/src/process.cpp
@@ -176,8 +176,12 @@ bool xorg::testing::Process::WaitForExit(unsigned int timeout) {
d_->state = FINISHED_FAILURE;
}
return true;
- } else
+ } else {
+ /* prevent callers from getting odd erros if they check for errno */
+ if (pid == 0)
+ errno = 0;
return (pid == -1 && errno == ECHILD);
+ }
}
bool xorg::testing::Process::KillSelf(int signal, unsigned int timeout) {
--
1.8.0.2
More information about the xorg-devel
mailing list