diff --git a/c/pongd.c b/c/pongd.c index 0171606..95f712e 100644 --- a/c/pongd.c +++ b/c/pongd.c @@ -50,7 +50,14 @@ int main(int argc, char**argv) { printf ("Set the timer to two seconds.\n"); ipc_context_timer (ctx, 2000); - printf ("Loop over events.\n"); + printf ("Listening to the standard input (press enter to quit).\n"); + ret = ipc_add_external (ctx, 0); + + if (ret != 0) { + return err (ctx, "Cannot listen to standard input."); + } + + printf ("Loop over events. Press enter to quit.\n"); char should_continue = 1; size_t count = 0; size_t count_timer = 0; @@ -68,7 +75,11 @@ int main(int argc, char**argv) { switch ((enum event_types) event_type) { case ERROR: return err(ctx, "Error."); - case EXTERNAL: return err(ctx, "External (shouldn't happen)."); + case EXTERNAL: { + printf("Quitting!\n"); + should_continue = 0; + break; + } case SWITCH_RX: return err(ctx, "Switch RX (shouldn't happen)."); case SWITCH_TX: return err(ctx, "Switch TX (shouldn't happen)."); case CONNECTION: { printf ("New connection.\n"); break; }