diff options
Diffstat (limited to 'git_hooks_client/git_hooks_client.c')
-rw-r--r-- | git_hooks_client/git_hooks_client.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/git_hooks_client/git_hooks_client.c b/git_hooks_client/git_hooks_client.c index 01af196..9050181 100644 --- a/git_hooks_client/git_hooks_client.c +++ b/git_hooks_client/git_hooks_client.c @@ -68,6 +68,25 @@ int main(void) { return EXIT_FAILURE; } + char status_buf[1]; + ssize_t bytes_read = read(sock, status_buf, 1); + switch (bytes_read) { + case -1: + perror("read"); + close(sock); + return EXIT_FAILURE; + case 0: + dprintf(STDERR_FILENO, "fatal: unexpected EOF on internal socket\n"); + close(sock); + return EXIT_FAILURE; + case 1: + break; + default: + dprintf(STDERR_FILENO, "fatal: read returned unexpected value on internal socket\n"); + close(sock); + return EXIT_FAILURE; + } + close(sock); - return EXIT_SUCCESS; + return *status_buf; } |