Skip to content

Commit

Permalink
Switched to using vfork().
Browse files Browse the repository at this point in the history
It causes less xruns when launching a new plugin instance, even if
the launch happens from a non-real time thread. Presumably, fork()
blocks all threads in the parent task while the process is cloned,
while vfork() doesn't make a copy and therefore doesn't block.
  • Loading branch information
falkTX committed Aug 27, 2012
1 parent fae6ae9 commit 0dd6cd4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions remotevstclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,16 @@ RemoteVSTClient::RemoteVSTClient(std::string dllName, bool showGUI) :
std::cerr << "RemoteVSTClient: executing "
<< fileName << " " << argStr << std::endl;

if ((child = fork()) < 0) {
const char* fileNameStr = fileName.c_str();
if ((child = vfork()) < 0) {
cleanup();
throw((std::string)"Fork failed");
} else if (child == 0) { // child process
if (execlp(fileName.c_str(), fileName.c_str(), argStr, NULL)) {
if (execlp(fileNameStr, fileNameStr, argStr, NULL)) {
// vfork() docs say you shouldn't call a function here,
// but it seems to work for me.
perror("Exec failed");
exit(1);
_exit(1);
}
}

Expand Down

0 comments on commit 0dd6cd4

Please sign in to comment.