BUG #3462: pg_ctl error output cannot be redirected - Mailing list pgsql-bugs

From Eugene Gershnik
Subject BUG #3462: pg_ctl error output cannot be redirected
Date
Msg-id 200707180319.l6I3JKgE024141@wwwmaster.postgresql.org
Whole thread Raw
List pgsql-bugs
The following bug has been logged online:

Bug reference:      3462
Logged by:          Eugene Gershnik
Email address:      gershnik@hotmail.com
PostgreSQL version: 8.2.4
Operating system:   Windows
Description:        pg_ctl error output cannot be redirected
Details:

On Windows an attempt to do

pg_ctl ... > file.txt 2>&1

where ... stands for any parameters that make pg_ctl fail sends stderr
output to event log rather than file.txt.
This is caused by the following incorrect test in pg_ctl.c in function
write_stderr(const char *fmt,...)

if (!isatty(fileno(stderr)))
...

This test will succeed for anything other than console being stderr. It is
obviously incorrect since when the output is redirected to a file or pipe
you also want to print it rather than to send it to event log. What you need
to test is whether GetStdHandle returns an invalid handle.

pgsql-bugs by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: BUG #3431: age() gets the days wrong
Next
From: "Alex"
Date:
Subject: BUG #3467: Sum strange behaviour