Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
donald committed Feb 21, 2022
1 parent 523b995 commit 218e94a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions mx_util.c
Expand Up @@ -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;
}

Expand All @@ -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';
Expand Down
6 changes: 3 additions & 3 deletions test_mx_util.c
Expand Up @@ -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);

}

Expand Down

0 comments on commit 218e94a

Please sign in to comment.