Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef FRONTEND
00018 #include "postgres.h"
00019 #else
00020 #include "postgres_fe.h"
00021 #endif
00022
00023 #include <signal.h>
00024 #include <stdio.h>
00025 #include <string.h>
00026 #include <sys/wait.h>
00027
00028
00029
00030
00031
00032
00033 char *
00034 wait_result_to_str(int exitstatus)
00035 {
00036 char str[512];
00037
00038 if (WIFEXITED(exitstatus))
00039 {
00040
00041
00042
00043
00044 switch (WEXITSTATUS(exitstatus))
00045 {
00046 case 126:
00047 snprintf(str, sizeof(str), _("command not executable"));
00048 break;
00049
00050 case 127:
00051 snprintf(str, sizeof(str), _("command not found"));
00052 break;
00053
00054 default:
00055 snprintf(str, sizeof(str),
00056 _("child process exited with exit code %d"),
00057 WEXITSTATUS(exitstatus));
00058 }
00059 }
00060 else if (WIFSIGNALED(exitstatus))
00061 #if defined(WIN32)
00062 snprintf(str, sizeof(str),
00063 _("child process was terminated by exception 0x%X"),
00064 WTERMSIG(exitstatus));
00065 #elif defined(HAVE_DECL_SYS_SIGLIST) && HAVE_DECL_SYS_SIGLIST
00066 {
00067 char str2[256];
00068
00069 snprintf(str2, sizeof(str2), "%d: %s", WTERMSIG(exitstatus),
00070 WTERMSIG(exitstatus) < NSIG ?
00071 sys_siglist[WTERMSIG(exitstatus)] : "(unknown)");
00072 snprintf(str, sizeof(str),
00073 _("child process was terminated by signal %s"), str2);
00074 }
00075 #else
00076 snprintf(str, sizeof(str),
00077 _("child process was terminated by signal %d"),
00078 WTERMSIG(exitstatus));
00079 #endif
00080 else
00081 snprintf(str, sizeof(str),
00082 _("child process exited with unrecognized status %d"),
00083 exitstatus);
00084
00085 return pstrdup(str);
00086 }