Re: Win32 testing needed
Tom Lane <[email protected]>
| Newsgroups | gmane.comp.db.postgresql.devel.win32 |
|---|---|
| Message-ID | <[email protected]> |
Andreas Pflug <[email protected]> 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 ---------------------------(end of broadcast)--------------------------- TIP 2: you can get off all lists at once with the unregister command (send "unregister YourEmailAddressHere" to [email protected])