From bd2ad340e61be08b3cfb615c94cbfb708617eb59 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Mon, 3 Mar 2025 21:34:51 +0800 Subject: hooks: Comment on how using the first byte as return doesn't make sense --- git_hooks_client/git_hooks_client.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/git_hooks_client/git_hooks_client.c b/git_hooks_client/git_hooks_client.c index 46fd02a..fc49d91 100644 --- a/git_hooks_client/git_hooks_client.c +++ b/git_hooks_client/git_hooks_client.c @@ -177,11 +177,17 @@ int main(int argc, char *argv[]) { return EXIT_FAILURE; } - /* - * The first byte of the response from the UNIX domain socket is the - * status code. We read it and record it as our return value. - */ - char status_buf[1]; + /* + * The first byte of the response from the UNIX domain socket is the + * status code. We read it and record it as our return value. + * + * FIXME: It doesn't make sense to require the return value to be + * sent before the log message. However, if we were to keep splicing, + * it's difficult to get the last byte before EOF. Perhaps we could + * hack together some sort of OOB message or ancillary data, or perhaps + * even use signals. + */ + char status_buf[1]; ssize_t bytes_read = read(sock, status_buf, 1); switch (bytes_read) { case -1: -- cgit v1.2.3