Make failure to open psql's --log-file fatal.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 8 Dec 2015 22:14:46 +0000 (17:14 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 8 Dec 2015 22:14:46 +0000 (17:14 -0500)
Commit 344cdff2c made failure to open the target of --output fatal.
For consistency, the --log-file switch should behave similarly.
Like the previous commit, back-patch to 9.5 but no further.

Daniel Verite

src/bin/psql/startup.c

index 7af38fbab0a294555ac7fac40c5fb87a78dd8aa1..17fb943dfab7bd9133b5f28fd7ec9cfc11fb4d6b 100644 (file)
@@ -287,8 +287,11 @@ main(int argc, char *argv[])
    {
        pset.logfile = fopen(options.logfilename, "a");
        if (!pset.logfile)
+       {
            fprintf(stderr, _("%s: could not open log file \"%s\": %s\n"),
                    pset.progname, options.logfilename, strerror(errno));
+           exit(EXIT_FAILURE);
+       }
    }
 
    if (!options.no_psqlrc)