diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2022-08-29 13:55:38 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2022-08-29 13:55:41 -0400 |
commit | 7fed801135bae14d63b11ee4a10f6083767046d8 (patch) | |
tree | 73fa489ffb169fe62ae066ef5cfe6a39a8fa6163 /src/backend/postmaster/fork_process.c | |
parent | 20796536c10fe7869e7af2c69615f14a80555c5d (diff) | |
download | postgresql-7fed801135bae14d63b11ee4a10f6083767046d8.tar.gz postgresql-7fed801135bae14d63b11ee4a10f6083767046d8.zip |
Clean up inconsistent use of fflush().
More than twenty years ago (79fcde48b), we hacked the postmaster
to avoid a core-dump on systems that didn't support fflush(NULL).
We've mostly, though not completely, hewed to that rule ever since.
But such systems are surely gone in the wild, so in the spirit of
cleaning out no-longer-needed portability hacks let's get rid of
multiple per-file fflush() calls in favor of using fflush(NULL).
Also, we were fairly inconsistent about whether to fflush() before
popen() and system() calls. While we've received no bug reports
about that, it seems likely that at least some of these call sites
are at risk of odd behavior, such as error messages appearing in
an unexpected order. Rather than expend a lot of brain cells
figuring out which places are at hazard, let's just establish a
uniform coding rule that we should fflush(NULL) before these calls.
A no-op fflush() is surely of trivial cost compared to launching
a sub-process via a shell; while if it's not a no-op then we likely
need it.
Discussion: https://postgr.es/m/2923412.1661722825@sss.pgh.pa.us
Diffstat (limited to 'src/backend/postmaster/fork_process.c')
-rw-r--r-- | src/backend/postmaster/fork_process.c | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/src/backend/postmaster/fork_process.c b/src/backend/postmaster/fork_process.c index c75be03d2c3..ec677614870 100644 --- a/src/backend/postmaster/fork_process.c +++ b/src/backend/postmaster/fork_process.c @@ -37,13 +37,8 @@ fork_process(void) /* * Flush stdio channels just before fork, to avoid double-output problems. - * Ideally we'd use fflush(NULL) here, but there are still a few non-ANSI - * stdio libraries out there (like SunOS 4.1.x) that coredump if we do. - * Presently stdout and stderr are the only stdio output channels used by - * the postmaster, so fflush'ing them should be sufficient. */ - fflush(stdout); - fflush(stderr); + fflush(NULL); #ifdef LINUX_PROFILE |