From 60d587c7e55b1ae9f15c060361a0a59645030d21 Mon Sep 17 00:00:00 2001 From: Yegor Lukash Date: Tue, 11 Aug 2026 06:53:21 +0300 Subject: [PATCH] Report the shutdown from the batch loop, not the signal handler --- src/main.zig | 3 ++- src/processor/processor.zig | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.zig b/src/main.zig index 6b773d2..b0cf07d 100644 --- a/src/main.zig +++ b/src/main.zig @@ -221,9 +221,10 @@ fn printStatus(comptime fmt: []const u8, args: anytype) void { }; } +// Only the atomic store: a log here would rebind the shared stderr writer under +// the interrupted call and can block on the stderr lock. The batch loop reports it. fn handleShutdownSignal(_: posix.SIG) callconv(.c) void { shutdown_requested.store(true, .seq_cst); - std.log.info("Shutdown signal received, initiating graceful shutdown...", .{}); } fn setupSignalHandlers() void { diff --git a/src/processor/processor.zig b/src/processor/processor.zig index 2e6509d..3cdf470 100644 --- a/src/processor/processor.zig +++ b/src/processor/processor.zig @@ -403,6 +403,9 @@ pub const Processor = struct { } } + // The signal handler only sets the flag, so the acknowledgement comes from here. + std.log.info("Shutdown requested, finishing the process...", .{}); + // Graceful stop: cancel and await the worker (runs its final flush/commit) // before reporting the stream stopped. flush_future.cancel(io);