diff --git a/userspace/falco/app/actions/process_events.cpp b/userspace/falco/app/actions/process_events.cpp index 33059304326..98d793b79d2 100644 --- a/userspace/falco/app/actions/process_events.cpp +++ b/userspace/falco/app/actions/process_events.cpp @@ -585,6 +585,12 @@ falco::app::run_result falco::app::actions::process_events(falco::app::state& s) } } + // By deleting s.outputs, we make sure that the engine will wait until + // regular output has been completely sent before printing stats, avoiding + // intermixed stats with output. + // Note that this will only work if this is the last reference held by the + // shared pointer. + s.outputs.reset(); s.engine->print_stats(); return res;