Re: Win32 testing needed

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Win32 testing needed
Дата
Msg-id 18894.1091808733@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Win32 testing needed  (Andreas Pflug <pgadmin@pse-consulting.de>)
Ответы Re: Win32 testing needed
Список pgsql-hackers-win32
Andreas Pflug <pgadmin@pse-consulting.de> writes:
> Apparently, this is a mixture of binary and text file mode. Initially,
> stderr is in text mode. When redirecting with dup2, it will be binary;
> this must be corrected with

> dup2(_open_osfhandle(...., _O_APPEND | _O_TEXT), ...

Okay, I added _O_TEXT to that call; the #ifdef WIN32 part now looks like

                fflush(stderr);
                if (dup2(_open_osfhandle((long)syslogPipe[1],
                                         _O_APPEND | _O_TEXT),
                         _fileno(stderr)) < 0)
                    ereport(FATAL,
                            (errcode_for_file_access(),
                             errmsg("could not redirect stderr: %m")));
                /* Now we are done with the write end of the pipe. */
                CloseHandle(syslogPipe[1]);
                syslogPipe[1] = 0;

One question about this: isn't this coding leaking a file descriptor?
That is, shouldn't we catch the result of _open_osfhandle and do a
CloseHandle on it after the dup2 step?

BTW, is it correct to use 0 as "invalid handle"?  Or should we be using
-1 or some such?

> Now, the pipe ReadFile will receive completely formatted data, which
> must be written binary (otherwise we will get CRCRLF), OTOH, the
> logger's calls to write_syslogger_file should write in text mode or
> replace \n by \r\n. Seems we need another function for elog to call.

Yeah.  What do you think is the most convenient way to do that?  I'd
be inclined to build a function that just expands \n to \r\n and then
calls write_syslogger_file, but maybe there's an easier way.

            regards, tom lane

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

Предыдущее
От: "Merlin Moncure"
Дата:
Сообщение: Re: Point in Time recovery on Win32
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Win32 testing needed