aboutsummaryrefslogtreecommitdiff
path: root/zencore/thread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'zencore/thread.cpp')
-rw-r--r--zencore/thread.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/zencore/thread.cpp b/zencore/thread.cpp
index 0f2dc7181..3b69b7a1e 100644
--- a/zencore/thread.cpp
+++ b/zencore/thread.cpp
@@ -22,6 +22,7 @@
# include <pthread.h>
# include <signal.h>
# include <sys/file.h>
+# include <sys/wait.h>
# include <time.h>
# include <unistd.h>
#endif
@@ -585,10 +586,8 @@ ProcessHandle::Wait(int TimeoutMs)
timespec SleepTime = { 0, SleepMs * 1000 * 1000 };
for (int i = 0; ; i += SleepMs)
{
- if (TimeoutMs >= 0 && i >= TimeoutMs)
- {
- return false;
- }
+ int WaitState = 0;
+ waitpid(m_Pid, &WaitState, WNOHANG|WCONTINUED|WUNTRACED);
if (kill(m_Pid, 0) < 0)
{
@@ -599,6 +598,11 @@ ProcessHandle::Wait(int TimeoutMs)
break;
}
+ if (TimeoutMs >= 0 && i >= TimeoutMs)
+ {
+ return false;
+ }
+
nanosleep(&SleepTime, nullptr);
}
#else