Implement ProcessMonitor::Kill for FreeBSD
authorEd Maste <emaste@freebsd.org>
Tue, 1 Apr 2014 14:30:56 +0000 (14:30 +0000)
committerEd Maste <emaste@freebsd.org>
Tue, 1 Apr 2014 14:30:56 +0000 (14:30 +0000)
On FreeBSD ptrace(PT_KILL) is used to terminate the traced process
(as if PT_CONTINUE had been used with SIGKILL as the signal to be
delivered), and is the desired behaviour for ProcessPOSIX::DoDestroy.

On Linux, after ptrace(PTRACE_KILL) the traced process still exists
and can be interrogated.  It is only upon resume that it exits as though
it received SIGKILL.

For now I'm committing only the FreeBSD change, until the Linux change
(review D3159) is successfully tested.

http://llvm.org/pr18894

llvm-svn: 205315

lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.cpp
lldb/source/Plugins/Process/FreeBSD/ProcessMonitor.h
lldb/source/Plugins/Process/POSIX/ProcessPOSIX.cpp

index ba5342efb27973956f1732aca2dc97e55bd6d230..c8f85821dbf8165f27760d0f8935e010bd74c405 100644 (file)
@@ -702,7 +702,7 @@ EventMessageOperation::Execute(ProcessMonitor *monitor)
 
 //------------------------------------------------------------------------------
 /// @class KillOperation
-/// @brief Implements ProcessMonitor::BringProcessIntoLimbo.
+/// @brief Implements ProcessMonitor::Kill.
 class KillOperation : public Operation
 {
 public:
@@ -1648,7 +1648,7 @@ ProcessMonitor::SingleStep(lldb::tid_t unused, uint32_t signo)
 }
 
 bool
-ProcessMonitor::BringProcessIntoLimbo()
+ProcessMonitor::Kill()
 {
     bool result;
     KillOperation op(result);
index 4c8198fb2e4c56f838c5380afb1b94cb01cd815e..ad8880951472461dbbac6c0ddc83550e4399ec7d 100644 (file)
@@ -194,11 +194,9 @@ public:
     bool
     SingleStep(lldb::tid_t unused, uint32_t signo);
 
-    /// Sends the inferior process a PTRACE_KILL signal.  The inferior will
-    /// still exists and can be interrogated.  Once resumed it will exit as
-    /// though it received a SIGKILL.
+    /// Terminate the traced process.
     bool
-    BringProcessIntoLimbo();
+    Kill();
 
     lldb_private::Error
     Detach(lldb::tid_t tid);
index 4ee7e3d3820be9dc31f43d336b2f0dbf55ef9860..571818134d44249045b7f3d1a21900ddc885f3be 100644 (file)
@@ -337,11 +337,13 @@ ProcessPOSIX::DoDestroy()
 
     if (!HasExited())
     {
-        // Drive the exit event to completion (do not keep the inferior in
-        // limbo).
+        assert(m_monitor);
         m_exit_now = true;
-
+#ifdef __linux__
         if ((m_monitor == NULL || kill(m_monitor->GetPID(), SIGKILL)) && error.Success())
+#else
+        if (!m_monitor->Kill())
+#endif
         {
             error.SetErrorToErrno();
             return error;