Use getpgid() with waitpid() in case the process pgid is not equal to its pid, as is the case with a forked subprocess. Also a couple of fixes for unit test failures from Todd Fiala.

llvm-svn: 205405
diff --git a/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp b/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
index 47e1135..94892b1 100644
--- a/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
+++ b/lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp
@@ -379,6 +379,8 @@
 void
 ProcessPOSIX::SendMessage(const ProcessMessage &message)
 {
+    Log *log (ProcessPOSIXLog::GetLogIfAllCategoriesSet (POSIX_LOG_PROCESS));
+
     Mutex::Locker lock(m_message_mutex);
 
     Mutex::Locker thread_lock(m_thread_list.GetMutex());
@@ -420,8 +422,14 @@
         break;
 
     case ProcessMessage::eExitMessage:
-        assert(thread);
-        thread->SetState(eStateExited);
+        if (thread != nullptr)
+            thread->SetState(eStateExited);
+        else
+        {
+            if (log)
+                log->Warning ("ProcessPOSIX::%s eExitMessage for TID %" PRIu64 " failed to find a thread to mark as eStateExited, ignoring", __FUNCTION__, message.GetTID ());
+        }
+
         // FIXME: I'm not sure we need to do this.
         if (message.GetTID() == GetID())
         {