diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2009-12-19 03:57:22 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2009-12-19 03:57:22 +0000 |
commit | 121f0a7775dc6df72896104cd8357ad3cd3323b6 (patch) | |
tree | f7461166c8e072af16b4bca404d1266a23ab8043 /lib | |
parent | 72d1261e86b2fba18a6f4840d2a2a5ab54974718 (diff) | |
download | netpbm-mirror-121f0a7775dc6df72896104cd8357ad3cd3323b6.tar.gz netpbm-mirror-121f0a7775dc6df72896104cd8357ad3cd3323b6.tar.xz netpbm-mirror-121f0a7775dc6df72896104cd8357ad3cd3323b6.zip |
Improve message telling how process died
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1063 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libsystem.c | 99 |
1 files changed, 94 insertions, 5 deletions
diff --git a/lib/libsystem.c b/lib/libsystem.c index 64ebc46a..1f697c7d 100644 --- a/lib/libsystem.c +++ b/lib/libsystem.c @@ -184,14 +184,103 @@ spawnProcessor(const char * const progName, } + +static const char * +signalName(unsigned int const signalClass) { + + if (signalClass <= SIGSYS) { + switch (signalClass) { + case SIGHUP: + return "SIGHUP"; + case SIGINT: + return "SIGINT"; + case SIGQUIT: + return "SIGQUIT"; + case SIGILL: + return "SIGILL"; + case SIGTRAP: + return "SIGTRAP"; + case SIGABRT: + return "SIGABRT"; + case SIGBUS: + return "SIGBUS"; + case SIGFPE: + return "SIGFPE"; + case SIGKILL: + return "SIGKILL"; + case SIGUSR1: + return "SIGUSR1"; + case SIGSEGV: + return "SIGSEGV"; + case SIGUSR2: + return "SIGUSR2"; + case SIGPIPE: + return "SIGPIPE"; + case SIGALRM: + return "SIGALRM"; + case SIGTERM: + return "SIGTERM"; + case SIGCHLD: + return "SIGCHLD"; + case SIGCONT: + return "SIGCONT"; + case SIGSTOP: + return "SIGSTOP"; + case SIGTSTP: + return "SIGTSTP"; + case SIGTTIN: + return "SIGTTIN"; + case SIGTTOU: + return "SIGTTOU"; + case SIGURG: + return "SIGURG"; + case SIGXCPU: + return "SIGXCPU"; + case SIGXFSZ: + return "SIGXFSZ"; + case SIGVTALRM: + return "SIGVTALRM"; + case SIGPROF: + return "SIGPROF"; + case SIGWINCH: + return "SIGWINCH"; + case SIGIO: + return "SIGIO"; + case SIGPWR: + return "SIGPWR"; + case SIGSYS: + return "SIGSYS"; + default: + return "???"; + } + } else if ((int)signalClass >= SIGRTMIN && (int)signalClass <= SIGRTMAX) + return "SIGRTxxx"; + else + return "???"; +} + + + static void cleanupProcessorProcess(pid_t const processorPid) { - int status; - waitpid(processorPid, &status, 0); - if (status != 0) - pm_message("Shell process ended abnormally. " - "completion code = %d", status); + int terminationStatus; + waitpid(processorPid, &terminationStatus, 0); + + if (WIFEXITED(terminationStatus)) { + int const exitStatus = WEXITSTATUS(terminationStatus); + + if (exitStatus != 0) + pm_message("Shell process exited with abnormal exist status %u. ", + exitStatus); + } else if (WIFSIGNALED(terminationStatus)) { + pm_message("Shell process was killed by a Class %u (%s) signal.", + WTERMSIG(terminationStatus), + signalName(WTERMSIG(terminationStatus))); + } else { + pm_message("Shell process died, but its termination status " + "0x%x doesn't make sense", terminationStatus); + } } |