Skip to content

Commit

Permalink
Merge pull request #424 from jakobrs/kill-button-patch
Browse files Browse the repository at this point in the history
Fix the Kill button killing libTAS itself
  • Loading branch information
clementgallet authored Jul 19, 2021
2 parents 2ae7dd5 + 8248343 commit f631ee8
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/program/ui/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1350,8 +1350,20 @@ void MainWindow::slotLaunch()
void MainWindow::slotStop()
{
if (context->status == Context::QUITTING) {
/* Terminate the game process */
kill(context->game_pid, SIGKILL);
if (context->game_pid != 0) {
/* Terminate the game process */
kill(context->game_pid, SIGKILL);
} else {
/* In this case, the game has closed (because game_pid has been set
* to 0 by loopExit) yet status is still QUITTING, because status
* depends on whether fork_pid is alive, not the game itself.
*
* So in this case, the game process and the forked process have
* different pids (which can happen with gdb, for example) and the
* game process has quit, but the forked process has not.
*/
kill(context->fork_pid, SIGKILL);
}
return;
}

Expand Down

0 comments on commit f631ee8

Please sign in to comment.