Browse Source

Clear PID when child process ends

tags/v2.3.0-RC1
falkTX 4 years ago
parent
commit
2c142d77af
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
5 changed files with 17 additions and 9 deletions
  1. +1
    -1
      source/backend/plugin/CarlaPluginBridge.cpp
  2. +1
    -1
      source/backend/plugin/CarlaPluginJack.cpp
  3. +1
    -1
      source/backend/plugin/CarlaPluginLADSPADSSI.cpp
  4. +12
    -4
      source/modules/water/threads/ChildProcess.cpp
  5. +2
    -2
      source/modules/water/threads/ChildProcess.h

+ 1
- 1
source/backend/plugin/CarlaPluginBridge.cpp View File

@@ -351,7 +351,7 @@ protected:
else
{
// forced quit, may have crashed
if (fProcess->getExitCode() != 0 /*|| fProcess->exitStatus() == QProcess::CrashExit*/)
if (fProcess->getExitCodeAndClearPID() != 0)
{
carla_stderr("CarlaPluginBridgeThread::run() - bridge crashed");



+ 1
- 1
source/backend/plugin/CarlaPluginJack.cpp View File

@@ -432,7 +432,7 @@ protected:
else
{
// forced quit, may have crashed
if (fProcess->getExitCode() != 0 /*|| fProcess->exitStatus() == QProcess::CrashExit*/)
if (fProcess->getExitCodeAndClearPID() != 0)
{
carla_stderr("CarlaPluginJackThread::run() - application crashed");



+ 1
- 1
source/backend/plugin/CarlaPluginLADSPADSSI.cpp View File

@@ -225,7 +225,7 @@ public:
carla_stdout("CarlaThreadDSSIUI::run() - UI auto-closed successfully");
}
}
else if (fProcess->getExitCode() != 0 /*|| fProcess->exitStatus() == QProcess::CrashExit*/)
else if (fProcess->getExitCodeAndClearPID() != 0)
carla_stderr("CarlaThreadDSSIUI::run() - UI crashed while running");
else
carla_stdout("CarlaThreadDSSIUI::run() - UI closed cleanly");


+ 12
- 4
source/modules/water/threads/ChildProcess.cpp View File

@@ -54,9 +54,15 @@ public:
}
~ActiveProcess()
{
closeProcessInfo();
}
void closeProcessInfo() noexcept
{
if (ok)
{
ok = false;
CloseHandle (processInfo.hThread);
CloseHandle (processInfo.hProcess);
}
@@ -88,10 +94,11 @@ public:
return TerminateProcess (processInfo.hProcess, 0) != FALSE;
}
uint32 getExitCode() const noexcept
uint32 getExitCodeAndClearPID() noexcept
{
DWORD exitCode = 0;
GetExitCodeProcess (processInfo.hProcess, &exitCode);
closeProcessInfo();
return (uint32) exitCode;
}
@@ -200,12 +207,13 @@ public:
return ::kill (childPID, SIGTERM) == 0;
}
uint32 getExitCode() const noexcept
uint32 getExitCodeAndClearPID() noexcept
{
if (childPID != 0)
{
int childState = 0;
const int pid = waitpid (childPID, &childState, WNOHANG);
childPID = 0;
if (pid >= 0 && WIFEXITED (childState))
return WEXITSTATUS (childState);
@@ -246,9 +254,9 @@ bool ChildProcess::terminate()
return activeProcess == nullptr || activeProcess->terminateProcess();
}
uint32 ChildProcess::getExitCode() const
uint32 ChildProcess::getExitCodeAndClearPID()
{
return activeProcess != nullptr ? activeProcess->getExitCode() : 0;
return activeProcess != nullptr ? activeProcess->getExitCodeAndClearPID() : 0;
}
bool ChildProcess::waitForProcessToFinish (const int timeoutMs)


+ 2
- 2
source/modules/water/threads/ChildProcess.h View File

@@ -81,8 +81,8 @@ public:
/** Blocks until the process is no longer running. */
bool waitForProcessToFinish (int timeoutMs);
/** If the process has finished, this returns its exit code. */
uint32 getExitCode() const;
/** If the process has finished, this returns its exit code and also clears assigned PID. */
uint32 getExitCodeAndClearPID();
/** Attempts to kill the child process.
Returns true if it succeeded. Trying to read from the process after calling this may


Loading…
Cancel
Save