Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2cfc8fc

Browse files
committed
FATAL errors should cause exit with nonzero status if we are not running
under the postmaster --- specifically, if we are a standalone backend running under the initdb script, this is critical!
1 parent e666422 commit 2cfc8fc

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/backend/utils/error/elog.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.81 2001/02/21 06:05:23 ishii Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.82 2001/03/10 04:21:51 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -451,7 +451,10 @@ elog(int lev, const char *fmt, ...)
451451
* after proc_exit has begun to run. (It's proc_exit's
452452
* responsibility to see that this doesn't turn into infinite
453453
* recursion!) But in the latter case, we exit with nonzero exit
454-
* code to indicate that something's pretty wrong.
454+
* code to indicate that something's pretty wrong. We also want
455+
* to exit with nonzero exit code if not running under the postmaster
456+
* (for example, if we are being run from the initdb script, we'd
457+
* better return an error status).
455458
*/
456459
if (lev == FATAL || !Warn_restart_ready || proc_exit_inprogress)
457460
{
@@ -463,7 +466,7 @@ elog(int lev, const char *fmt, ...)
463466
*/
464467
fflush(stdout);
465468
fflush(stderr);
466-
proc_exit((int) proc_exit_inprogress);
469+
proc_exit((int) (proc_exit_inprogress || !IsUnderPostmaster));
467470
}
468471

469472
/*

0 commit comments

Comments
 (0)