diff --git a/src/helpers/mterm/MTerm.cpp b/src/helpers/mterm/MTerm.cpp index 48798c33..d78c8847 100644 --- a/src/helpers/mterm/MTerm.cpp +++ b/src/helpers/mterm/MTerm.cpp @@ -41,7 +41,6 @@ #include #include #include "GMessage.h" -#include /* handshake interface */ typedef struct @@ -162,8 +161,6 @@ MTerm::MTerm(const BMessenger& msgr) : fExecProcessID(-1), fFd(-1), fMessenger(m MTerm::~MTerm() { Kill(); - syslog(LOG_INFO|LOG_PID|LOG_CONS|LOG_USER, "S) Genio: ~MTerm() called (fMessenger.IsValid() = %d)",fMessenger.IsValid()); - fMessenger = BMessenger(); } void @@ -181,8 +178,6 @@ MTerm::Run(int argc, const char* const* argv) void MTerm::Kill() { - syslog(LOG_INFO|LOG_PID|LOG_CONS|LOG_USER, "S) Genio: MTerm::Kill called (fExecProcessID %d fReadTask %p fFd %d)", fExecProcessID, fReadTask, fFd); - if (fReadTask) { fReadTask->Stop(); fReadTask = nullptr; @@ -195,7 +190,6 @@ MTerm::Kill() wait(&status); fFd = -1; } - syslog(LOG_INFO|LOG_PID|LOG_CONS|LOG_USER, "E) Genio: MTerm::Kill called (fExecProcessID %d fReadTask %p fFd %d)", fExecProcessID, fReadTask, fFd); } diff --git a/src/helpers/mterm/MTermView.cpp b/src/helpers/mterm/MTermView.cpp index 0993a801..aa696720 100644 --- a/src/helpers/mterm/MTermView.cpp +++ b/src/helpers/mterm/MTermView.cpp @@ -14,6 +14,7 @@ #include #include #include "KeyTextViewScintilla.h" +#include "Log.h" #undef B_TRANSLATION_CONTEXT #define B_TRANSLATION_CONTEXT "TermView" @@ -100,6 +101,25 @@ MTermView::MessageReceived(BMessage* message) break; } case Genio::Task::TASK_RESULT_MESSAGE: + { + // The task is ending. Let's avoid calling _EnsureStopped() (which terminates the task) + // before it has fully completed, to prevent potentially entering an inconsistent + // kernel lock state. + + thread_id taskId = (thread_id)message->GetInt32("TaskResult::TaskID", -1); + if (taskId > -1) { + status_t threadStatus = B_OK; + status_t waitStatus = wait_for_thread(taskId, &threadStatus); + LogInfo("TASK_RESULT_MESSAGE for thread %d: threadStatus (%s) waitStatus (%s)", + taskId, + strerror(threadStatus), + strerror(waitStatus)); + _EnsureStopped(); + } + + + break; + } case kTermViewStop: { _EnsureStopped();