diff options
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/access/transam/xlogarchive.c | 20 | ||||
-rw-r--r-- | src/backend/commands/copy.c | 3 | ||||
-rw-r--r-- | src/backend/postmaster/pgarch.c | 10 |
3 files changed, 10 insertions, 23 deletions
diff --git a/src/backend/access/transam/xlogarchive.c b/src/backend/access/transam/xlogarchive.c index b8da714b800..8bdb6ec3088 100644 --- a/src/backend/access/transam/xlogarchive.c +++ b/src/backend/access/transam/xlogarchive.c @@ -59,7 +59,6 @@ RestoreArchivedFile(char *path, const char *xlogfname, char *endp; const char *sp; int rc; - bool signaled; struct stat stat_buf; XLogSegNo restartSegNo; XLogRecPtr restartRedoPtr; @@ -289,17 +288,12 @@ RestoreArchivedFile(char *path, const char *xlogfname, * will perform an immediate shutdown when it sees us exiting * unexpectedly. * - * Per the Single Unix Spec, shells report exit status > 128 when a called - * command died on a signal. Also, 126 and 127 are used to report - * problems such as an unfindable command; treat those as fatal errors - * too. + * We treat hard shell errors such as "command not found" as fatal, too. */ - if (WIFSIGNALED(rc) && WTERMSIG(rc) == SIGTERM) + if (wait_result_is_signal(rc, SIGTERM)) proc_exit(1); - signaled = WIFSIGNALED(rc) || WEXITSTATUS(rc) > 125; - - ereport(signaled ? FATAL : DEBUG2, + ereport(wait_result_is_any_signal(rc, true) ? FATAL : DEBUG2, (errmsg("could not restore file \"%s\" from archive: %s", xlogfname, wait_result_to_str(rc)))); @@ -335,7 +329,6 @@ ExecuteRecoveryCommand(const char *command, const char *commandName, bool failOn char *endp; const char *sp; int rc; - bool signaled; XLogSegNo restartSegNo; XLogRecPtr restartRedoPtr; TimeLineID restartTli; @@ -403,12 +396,9 @@ ExecuteRecoveryCommand(const char *command, const char *commandName, bool failOn { /* * If the failure was due to any sort of signal, it's best to punt and - * abort recovery. See also detailed comments on signals in - * RestoreArchivedFile(). + * abort recovery. See comments in RestoreArchivedFile(). */ - signaled = WIFSIGNALED(rc) || WEXITSTATUS(rc) > 125; - - ereport((signaled && failOnSignal) ? FATAL : WARNING, + ereport((failOnSignal && wait_result_is_any_signal(rc, true)) ? FATAL : WARNING, /*------ translator: First %s represents a postgresql.conf parameter name like "recovery_end_command", the 2nd is the value of that parameter, the diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index 4aa8890fe81..4311e160076 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -17,7 +17,6 @@ #include <ctype.h> #include <unistd.h> #include <sys/stat.h> -#include <sys/wait.h> #include "access/heapam.h" #include "access/htup_details.h" @@ -1718,7 +1717,7 @@ ClosePipeToProgram(CopyState cstate) * problem. */ if (cstate->is_copy_from && !cstate->reached_eof && - WIFSIGNALED(pclose_rc) && WTERMSIG(pclose_rc) == SIGPIPE) + wait_result_is_signal(pclose_rc, SIGPIPE)) return; ereport(ERROR, diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c index 0dcf609f19a..f663d7befaf 100644 --- a/src/backend/postmaster/pgarch.c +++ b/src/backend/postmaster/pgarch.c @@ -627,13 +627,11 @@ pgarch_archiveXlog(char *xlog) * If either the shell itself, or a called command, died on a signal, * abort the archiver. We do this because system() ignores SIGINT and * SIGQUIT while waiting; so a signal is very likely something that - * should have interrupted us too. If we overreact it's no big deal, - * the postmaster will just start the archiver again. - * - * Per the Single Unix Spec, shells report exit status > 128 when a - * called command died on a signal. + * should have interrupted us too. Also die if the shell got a hard + * "command not found" type of error. If we overreact it's no big + * deal, the postmaster will just start the archiver again. */ - int lev = (WIFSIGNALED(rc) || WEXITSTATUS(rc) > 128) ? FATAL : LOG; + int lev = wait_result_is_any_signal(rc, true) ? FATAL : LOG; if (WIFEXITED(rc)) { |