From bfc9a5adc3f5d1643a0bbdbc6af762dd7c2bbd3e Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Tue, 21 Oct 2025 07:26:25 +0000 Subject: [PATCH] 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 --- src/daemon/command.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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) -- 2.47.3