From c7c0909f35481ac73e3adb6aef15d17cbbe6969e Mon Sep 17 00:00:00 2001 From: Karchnu Date: Mon, 20 Jul 2020 22:05:25 +0200 Subject: [PATCH] pongc now exits correctly. --- tests/pongc.cr | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/pongc.cr b/tests/pongc.cr index 62d1658..2d778cb 100644 --- a/tests/pongc.cr +++ b/tests/pongc.cr @@ -58,6 +58,8 @@ def main exit 1 end + nb_messages_remaining = CLI.rounds + # Listening on STDIN. client << 0 @@ -87,7 +89,11 @@ def main client.send message end when IPC::Event::MessageReceived - info "new message from #{event.fd}: #{event.message.to_s}" + nb_messages_remaining -= 1 + info "new message from #{event.fd}: #{event.message.to_s}, remaining #{nb_messages_remaining}" + if nb_messages_remaining == 0 + exit 0 + end when IPC::Event::Disconnection info "Disconnection from #{event.fd}" if event.fd == 0