From 218e94a7651bcc65c959e271e19b72da6ac860a6 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Fri, 18 Feb 2022 17:23:45 +0100 Subject: [PATCH] mx_call_external: Change EPIPE to EPROTO If an external helper does something unexpected like exiting with a non-zero exit status or sending more data than mxqd wants to handle, mx_call_external sets errno to an error code. Currenty we use EPIPE ("Broken pipe"). Change this to EPROTO ("Protocol error"), which seems to be better fitting. We assume that the external helper, which shares its stderr with mxqd, has already sent some diagnostic to the logfile. --- mx_util.c | 4 ++-- test_mx_util.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mx_util.c b/mx_util.c index 52e890de..7f99daf2 100644 --- a/mx_util.c +++ b/mx_util.c @@ -1360,7 +1360,7 @@ static char *mx_call_external_v(char *helper, char **argv) { goto err_close; } if (len == sizeof(buf)) { - err = EPIPE; + err = EPROTO; goto err_close; } @@ -1369,7 +1369,7 @@ static char *mx_call_external_v(char *helper, char **argv) { int wstatus; waitpid(pid, &wstatus, 0); if (wstatus != 0) { - err = EPIPE; + err = EPROTO; goto err_err; } buf[len] = '\0'; diff --git a/test_mx_util.c b/test_mx_util.c index e55d0070..028a9ebb 100644 --- a/test_mx_util.c +++ b/test_mx_util.c @@ -545,13 +545,13 @@ static void test_mx_call_external() { assert(errno == 999); line = mx_call_external("/usr/bin/false", NULL); - assert(line == NULL && errno==EPIPE); + assert(line == NULL && errno==EPROTO); line = mx_call_external("/usr/bin/cat", "/usr/bin/bash", NULL); - assert(line == NULL && errno==EPIPE); + assert(line == NULL && errno==EPROTO); line = mx_call_external("/usr/bin/yes", NULL); - assert(line == NULL && errno==EPIPE); + assert(line == NULL && errno==EPROTO); }