From: Michael Tremer Date: Thu, 4 Jun 2026 16:02:47 +0000 (+0000) Subject: command: Map back any negative return codes X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4719becc584ed288c05df42b233130d92d5bf5c4;p=telemetry.git command: Map back any negative return codes This is not perfect, but should be good enough since applications normally don't use any return codes larger than 128. Signed-off-by: Michael Tremer --- diff --git a/src/daemon/command.c b/src/daemon/command.c index 571a828..4c426a3 100644 --- a/src/daemon/command.c +++ b/src/daemon/command.c @@ -398,13 +398,20 @@ static int td_command_exited(sd_event_source* source, const siginfo_t* si, void* switch (si->si_code) { case CLD_EXITED: - DEBUG(self->ctx, "Process has exited with status code %d\n", si->si_status); - // Store the exit code rc = si->si_status; - // Log stderr + // Handle any errors if (rc) { + // Map back -errno + if (rc >= 128) + rc -= 256; + + if (rc >= 0) + DEBUG(self->ctx, "Process has exited with status code %d\n", rc); + else + DEBUG(self->ctx, "Process has exited with status: %s\n", strerror(-rc)); + // Log all lines r = td_file_walk(stderr, td_command_log_stderr, self); if (r < 0)