From: | Andreas Pflug <pgadmin(at)pse-consulting(dot)de> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers-win32(at)postgresql(dot)org |
Subject: | Re: Win32 testing needed |
Date: | 2004-08-06 18:41:40 |
Message-ID: | 4113D0E4.60703@pse-consulting.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers-win32 |
Tom Lane wrote:
> 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?
Yes, it does.
int fd=_open_osfhandle(....); // additional fdes from winhandle
_dup2(fd, ...)
close(fd);
>
> BTW, is it correct to use 0 as "invalid handle"? Or should we be using
> -1 or some such?
0 is usually ok, valid handles are never 0. The official value is
INVALID_HANDLE_VALUE which expands to (HANDLE)-1.
>
>
>>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.
We could have *two* handles open to the syslogger file, but that's
probably more fragile. Making the current write_syslogger_file static
and providing another function that converts in a local buffer and
calles write_syslogger_file seems best.
Regards,
Andreas
From | Date | Subject | |
---|---|---|---|
Next Message | Andreas Pflug | 2004-08-06 19:17:04 | Re: Win32 testing needed |
Previous Message | Andreas Pflug | 2004-08-06 18:26:34 | Re: Win32 testing needed |