Re: [EXIM] wish list: exit number translation ?

Top Page
Delete this message
Reply to this message
Author: Ben Smithurst
Date:  
To: exim-users
Subject: Re: [EXIM] wish list: exit number translation ?
Peter Radcliffe wrote:

> While this is useful, its not very informative to those who don't know
> about the existance of sysexits.h.
>
> Wish list: translation of the exit code to some more informative text.
> There doesn't seem to be a standard function to do this, but a case
> on EX_foo should be correct.


Well, it's ugly, and probably innefficient, but it might serve
until Philip comes up with something better, so here's a patch to
src/transports/pipe.c (v2.04) ... (also describes signal names, but I
haven't tested that bit. A lot of the signals probably don't need to
be in here, and I haven't included them all. Just the more common ones
could be included)

--- pipe.c~    Tue Sep 29 17:13:35 1998
+++ pipe.c    Tue Sep 29 17:54:23 1998
@@ -797,7 +797,31 @@
       {
       addr->transport_return = FAIL;
       addr->message = string_sprintf("Child process of %s transport (running "
-        "command \"%s\") was terminated by signal %d", tblock->name, cmd, -rc);
+        "command \"%s\")\nwas terminated by signal %d (%s)", tblock->name,
+        cmd, -rc
+        -rc == SIGHUP? "hangup" :
+        -rc == SIGINT? "interrupt" :
+        -rc == SIGQUIT? "quit" :
+        -rc == SIGILL? "illegal instruction" :
+        -rc == SIGTRAP? "trace trap" :
+        (-rc == SIGABRT || -rc == SIGIOT)? "abort" :
+        -rc == SIGEMT? "EMT instruction" :
+        -rc == SIGFPE? "floating point exception" :
+        -rc == SIGKILL? "killed" :
+        -rc == SIGBUS? "bus error" :
+        -rc == SIGSEGV? "segmentation fault" :
+        -rc == SIGSYS? "nonexistent system call" :
+        -rc == SIGPIPE? "broken pipe" :
+        -rc == SIGALRM? "alarm" :
+        -rc == SIGTERM? "terminated" :
+        -rc == SIGURG? "urgent condition on I/O channel" :
+        -rc == SIGSTOP? "stop" :
+        -rc == SIGTSTP? "stop from tty" :
+        -rc == SIGCHLD? "child stop or exit" :
+        -rc == SIGXCPU? "exceeded CPU limit" :
+        -rc == SIGXFSZ? "exceeded file size limit" :
+        -rc == SIGUSR1? "user defined signal 1" :
+        -rc == SIGUSR2? "user defined signal 2" : "unknown signal");
       }
     }


@@ -871,8 +895,24 @@
       /* Ensure the message contains the expanded command and arguments. This
       doesn't have to be brilliantly efficient - it is an error situation. */


-      addr->message = string_sprintf("Child process of %s transport returned "
-        "%d from command:", tblock->name, rc);
+      addr->message = string_sprintf("Child process of %s transport returned\n"
+        "%d (%s) from command:", tblock->name, rc,
+        rc == EX_USAGE? "usage or syntax error" :
+        rc == EX_DATAERR? "error in input data" :
+        rc == EX_NOINPUT? "input data missing" :
+        rc == EX_NOUSER? "user nonexistent" :
+        rc == EX_NOHOST? "host nonexistent" :
+        rc == EX_UNAVAILABLE? "service or program unavailable" :
+        rc == EX_SOFTWARE? "internal software error" :
+        rc == EX_OSERR? "internal operating system error" :
+        rc == EX_OSFILE? "system file missing" :
+        rc == EX_CANTCREAT? "can't create output" :
+        rc == EX_IOERR? "input/output error" :
+        rc == EX_TEMPFAIL? "temporary error" :
+        rc == EX_PROTOCOL? "protocol error" :
+        rc == EX_NOPERM? "permission denied" :
+        rc == EX_CONFIG? "local configuration error" :
+          "unknown exit code");
       ptr = (int)strlen(addr->message);
       size = ptr + 1;
       for (i = 0; i < sizeof(argv)/sizeof(int *) && argv[i] != NULL; i++)


Ugly, inefficient, and probably slow. (But it works. And that's (sort
of) what matters. <g>) I'm sure Philip will do better than I can.

--
Ben Smithurst : ben@??? : http://www.scientia.demon.co.uk/

PGP: 0x99392F7D - 3D 89 87 42 CE CA 93 4C  68 32 0E D5 36 05 3D 16
     http://www.scientia.demon.co.uk/ben/pgp-key.html (or use keyservers)



--
*** Exim information can be found at http://www.exim.org/ ***