Further tweaking of the readfile() function in pg_ctl.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 18 Oct 2012 19:26:26 +0000 (22:26 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 18 Oct 2012 19:26:26 +0000 (22:26 +0300)
commit2a49585e2b2ee43618e9f1107e21781c5f71f6c1
tree51a8e62cdac19749e79ac4938830d168393a32a2
parent160984c8c84afb1406acd7ab71982bcae26b07fe
Further tweaking of the readfile() function in pg_ctl.

Don't leak a file descriptor if the file is empty or we can't read its size.

Expect there to be a newline at the end of the last line, too. If there
isn't, ignore anything after the last newline. This makes it a tiny bit
more robust in case the file is appended to concurrently, so that we don't
return the last line if it hasn't been fully written yet. And this makes
the code a bit less obscure, anyway. Per Tom Lane's suggestion.

Backpatch to all supported branches.
src/bin/pg_ctl/pg_ctl.c