From: Michael Tremer Date: Tue, 21 Oct 2025 07:26:25 +0000 (+0000) Subject: command: Cleanup events before closing file descriptors X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bfc9a5adc3f5d1643a0bbdbc6af762dd7c2bbd3e;p=telemetry.git command: Cleanup events before closing file descriptors This makes the trace slightly cleaner when FDs will be removed from the event loop before they are closed and not the other way round. Signed-off-by: Michael Tremer --- diff --git a/src/daemon/command.c b/src/daemon/command.c index 6d8a145..9c01c81 100644 --- a/src/daemon/command.c +++ b/src/daemon/command.c @@ -101,6 +101,16 @@ static void td_command_close_pipe(int fds[2]) { } static void td_command_free(td_command* self) { + // Free events + if (self->events.timeout) + sd_event_source_unref(self->events.timeout); + if (self->events.exit) + sd_event_source_unref(self->events.exit); + if (self->events.stdout) + sd_event_source_unref(self->events.stdout); + if (self->events.stderr) + sd_event_source_unref(self->events.stderr); + // Close pipes td_command_close_pipe(self->stdout.pipes); td_command_close_pipe(self->stderr.pipes); @@ -115,16 +125,6 @@ static void td_command_free(td_command* self) { if (self->stderr.buffer) td_buffer_unref(self->stderr.buffer); - // Free events - if (self->events.timeout) - sd_event_source_unref(self->events.timeout); - if (self->events.exit) - sd_event_source_unref(self->events.exit); - if (self->events.stdout) - sd_event_source_unref(self->events.stdout); - if (self->events.stderr) - sd_event_source_unref(self->events.stderr); - if (self->loop) sd_event_unref(self->loop); if (self->daemon)