From fe4cdceb15b670ced1d7328c8c8bb4bd593521db Mon Sep 17 00:00:00 2001
From: winlin <winlin@vip.126.com>
Date: Wed, 26 Aug 2015 23:02:54 +0800
Subject: [PATCH] always wait for process to terminated when SIGKILL.

---
 trunk/src/app/srs_app_utility.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/trunk/src/app/srs_app_utility.cpp b/trunk/src/app/srs_app_utility.cpp
index 2d95d3dee..39bf83ce4 100644
--- a/trunk/src/app/srs_app_utility.cpp
+++ b/trunk/src/app/srs_app_utility.cpp
@@ -274,8 +274,11 @@ int srs_kill_forced(int& pid)
     // other signals, directly exit(123), for example:
     //        9) SIGKILL    15) SIGTERM
     int status = 0;
-    if (waitpid(pid, &status, 0) < 0) {
-        return ERROR_SYSTEM_KILL;
+    // @remark when we use SIGKILL to kill process, it must be killed,
+    //      so we always wait it to quit by infinite loop.
+    while (waitpid(pid, &status, 0) < 0) {
+        st_usleep(10 * 1000);
+        continue;
     }
     
     srs_trace("SIGKILL stop process pid=%d ok.", pid);