Syslogger tries to write to /dev/null on Windows

Поиск
Список
Период
Сортировка
От Heikki Linnakangas
Тема Syslogger tries to write to /dev/null on Windows
Дата
Msg-id 4BB47F08.9040006@enterprisedb.com
обсуждение исходный текст
Ответы Re: Syslogger tries to write to /dev/null on Windows  (Magnus Hagander <magnus@hagander.net>)
Re: Syslogger tries to write to /dev/null on Windows  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
A customer is facing a problem on PostgreSQL 8.3.10 on Windows where the
syslogger process dies mysteriously every few hours under load. I
haven't yet figured out why, but when postmaster tries to respawn
syslogger, it doesn't start up but dies immediately.

The reason the relaunch fails is that in SysLoggerMain we have this:
>     /*
>      * If we restarted, our stderr is already redirected into our own input
>      * pipe.  This is of course pretty useless, not to mention that it
>      * interferes with detecting pipe EOF.    Point stderr to /dev/null. This
>      * assumes that all interesting messages generated in the syslogger will
>      * come through elog.c and will be sent to write_syslogger_file.
>      */
>     if (redirection_done)
>     {
>         int            fd = open(NULL_DEV, O_WRONLY, 0);
>
>         /*
>          * The closes might look redundant, but they are not: we want to be
>          * darn sure the pipe gets closed even if the open failed.    We can
>          * survive running with stderr pointing nowhere, but we can't afford
>          * to have extra pipe input descriptors hanging around.
>          */
>         close(fileno(stdout));
>         close(fileno(stderr));
>         dup2(fd, fileno(stdout));
>         dup2(fd, fileno(stderr));
>         close(fd);
>     }

NULL_DEV is defined in c.h as "/dev/null", which doesn't work on
windows. We have a port-specific #define DEVNULL which does work, we
should be using that.

Peter Eisentraut inadvertently fixed this for 8.4:

http://archives.postgresql.org/pgsql-committers/2008-12/msg00095.php

by removing NULL_DEV and using always DEVNULL, but back-branches need
that too. I'll leave NULL_DEV as it is just in case it's used by 3rd
party modules, but change the two uses of it to use DEVNULL.

--
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Jaime Casanova
Дата:
Сообщение: Re: BUG #5388: bortdagos
Следующее
От: Magnus Hagander
Дата:
Сообщение: Re: Syslogger tries to write to /dev/null on Windows