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 <michael.tremer@ipfire.org>
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)