client: don't log exit code when --no-wait is used, unless non-zero

When the following command is run:

    footclient --no-wait sh -c 'exit 42'

...the logged message is always:

    info: client.c:420: exit-code=0

...because fdm_client() just sends a phony exit code of 0, instead
of waiting for the child to exit, as would usually be the case.

Logging an incorrect exit code can be somewhat misleading. It seems
better to just log nothing, when no useful information is available.
This commit is contained in:
Craig Barnes 2021-07-04 10:31:20 +01:00
parent 07652d3b9e
commit 743b2f8c07

View file

@ -417,7 +417,8 @@ main(int argc, char *const *argv)
int exit_code;
ssize_t rcvd = recv(fd, &exit_code, sizeof(exit_code), 0);
LOG_INFO("exit-code=%d", exit_code);
if (!no_wait || exit_code != 0)
LOG_INFO("exit-code=%d", exit_code);
if (rcvd == -1 && errno == EINTR)
xassert(aborted);