Skip to content

Commit

Permalink
Kill processes on stop so that the GUI doesn't hang.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiw committed Aug 19, 2024
1 parent 5a325b1 commit 7fe5c94
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/pipeline/ExternVocoderStep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,17 @@ ExternVocoderStep::ExternVocoderStep(std::string scriptPath, int workingSampleRa

ExternVocoderStep::~ExternVocoderStep()
{
// Close pipes and wait for process to terminate.
// Close pipes and kill process. Hopefully the process
// will die on its own but if it doesn't, force kill it.
close(receiveStdoutFd_);
close(receiveStdinFd_);

kill(recvProcessId_, SIGTERM);
for (int count = 0; count < 5 && waitpid(recvProcessId_, NULL, WNOHANG) <= 0; count++)
{
sleep(1);
}
kill(recvProcessId_, SIGKILL);
waitpid(recvProcessId_, NULL, 0);
}

Expand Down

0 comments on commit 7fe5c94

Please sign in to comment.