| 1697 | } |
| 1698 | |
| 1699 | static void |
| 1700 | write_binary_to_file(const char *buffer, int count, FILE *fh) |
| 1701 | { |
| 1702 | int rc; |
| 1703 | |
| 1704 | #ifndef WIN32 |
| 1705 | rc = fwrite(buffer, 1, count, fh); |
| 1706 | #else |
| 1707 | EnterCriticalSection(&fileSection); |
| 1708 | rc = fwrite(buffer, 1, count, fh); |
| 1709 | LeaveCriticalSection(&fileSection); |
| 1710 | #endif |
| 1711 | |
| 1712 | /* |
| 1713 | * Try to report any failure. We mustn't use ereport because it would |
| 1714 | * just recurse right back here, but write_stderr is OK: it will write |
| 1715 | * either to the postmaster's original stderr, or to /dev/null, but never |
| 1716 | * to our input pipe which would result in a different sort of looping. |
| 1717 | */ |
| 1718 | if (rc != count) |
| 1719 | write_stderr("could not write to log file: %s\n", strerror(errno)); |
| 1720 | } |
| 1721 | |
| 1722 | |
| 1723 | /* -------------------------------- |
no test coverage detected