BUG #13594: pg_ctl.exe redirects stderr to Windows Events Log if stderr is redirected to pipe
От | ekocjan@gmail.com |
---|---|
Тема | BUG #13594: pg_ctl.exe redirects stderr to Windows Events Log if stderr is redirected to pipe |
Дата | |
Msg-id | 20150828104658.2089.83265@wrigleys.postgresql.org обсуждение исходный текст |
Ответы |
Re: BUG #13594: pg_ctl.exe redirects stderr to Windows Events
Log if stderr is redirected to pipe
|
Список | pgsql-bugs |
The following bug has been logged on the website: Bug reference: 13594 Logged by: Egon Kocjan Email address: ekocjan@gmail.com PostgreSQL version: 9.5alpha2 Operating system: Windows 8.1 Description: Hello Context: I run PostgreSQL as a part of a larger software package, pg_ctl is used to control PostgreSQL. I capture all subprocess stderr logs to make a complete report. Problem: On Windows (but not Unix!), PostgreSQL (any version) pg_ctl stops writing into stderr if stderr is not a character device. As a result, it's not possible to capture stderr of pg_ctl when using CreateProcess and STARTUPINFO.hStdError. It might be possible to create a workaround with a console buffer, but I think it's quite ugly: http://www.codeproject.com/Articles/16163/Real-Time-Console-Output-Redirection Solution: Fix pg_ctl to write into stderr, if stderr is available and not just a character device. Possibly, add a flag to force stderr. I don't have the big picture, but this is the quick solution that I use right now: diff -ur postgresql-9.3.6.orig\src\bin\pg_ctl\pg_ctl.c postgresql-9.3.6\src\bin\pg_ctl\pg_ctl.c --- postgresql-9.3.6.orig\src\bin\pg_ctl\pg_ctl.c Mon Feb 02 22:43:50 2015 +++ postgresql-9.3.6\src\bin\pg_ctl\pg_ctl.c Fri Aug 28 08:21:01 2015 @@ -215,7 +215,7 @@ * On Win32, we print to stderr if running on a console, or write to * eventlog if running as a service */ - if (!isatty(fileno(stderr))) /* Running as a service */ + if (getenv("PG_CTL_STDERR") == NULL && !isatty(fileno(stderr))) /* Running as a service */ { char errbuf[2048]; /* Arbitrary size? */ Then in my main process: _putenv("PG_CTL_STDERR=1") I also noticed, that write_stderr() in src/backend/utils/error/elog.c uses a different check (not isatty): if (pgwin32_is_service()) /* Running as a service */ Thank you
В списке pgsql-bugs по дате отправления: