summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Smeding <tom.smeding@gmail.com>2018-08-20 23:37:48 +0200
committerTom Smeding <tom.smeding@gmail.com>2018-08-20 23:37:48 +0200
commit974a5a213bd780f5021c3e3d40ffad05e3c0a23e (patch)
tree2dc24a08f1305148cfb0d9433c89fbecf9599199
parentf62f1505da4cd68246ce40ad3cbccd81df1189df (diff)
Kill referee on player timeout
-rw-r--r--main.cpp1
-rw-r--r--referee.cpp4
-rw-r--r--referee.h3
3 files changed, 8 insertions, 0 deletions
diff --git a/main.cpp b/main.cpp
index 3dca757..5a6c779 100644
--- a/main.cpp
+++ b/main.cpp
@@ -278,6 +278,7 @@ static void playMatch(Player &p1, Player &p2, int index, const Params &params) {
if (mres.ms1 / 1000 > timeout_msec || mres.ms2 / 1000 > timeout_msec) {
mres.status = MatchResult::Status::timeout;
mres.sc1 = mres.sc2 = 0;
+ referee.terminate();
goto match_done;
}
diff --git a/referee.cpp b/referee.cpp
index 3f15b6b..7bf3a93 100644
--- a/referee.cpp
+++ b/referee.cpp
@@ -90,3 +90,7 @@ optional<vector<int>> Referee::getScores() {
if (isEnd) return scores;
else return nullopt;
}
+
+void Referee::terminate() {
+ proc.terminate();
+}
diff --git a/referee.h b/referee.h
index 5f278c5..0121196 100644
--- a/referee.h
+++ b/referee.h
@@ -25,6 +25,9 @@ public:
bool gameEnded();
optional<vector<int>> getScores();
+
+ // Kills the referee process
+ void terminate();
};
/*