* if they fail then presumably the file descriptors are closed and
* any writes will go into the bitbucket anyway.
*/
- close(fileno(stdout));
- close(fileno(stderr));
+ close(STDOUT_FILENO);
+ close(STDERR_FILENO);
if (fd != -1)
{
- (void) dup2(fd, fileno(stdout));
- (void) dup2(fd, fileno(stderr));
+ (void) dup2(fd, STDOUT_FILENO);
+ (void) dup2(fd, STDERR_FILENO);
close(fd);
}
}
*/
#ifdef WIN32
else
- _setmode(_fileno(stderr), _O_TEXT);
+ _setmode(STDERR_FILENO, _O_TEXT);
#endif
/*
#ifndef WIN32
fflush(stdout);
- if (dup2(syslogPipe[1], fileno(stdout)) < 0)
+ if (dup2(syslogPipe[1], STDOUT_FILENO) < 0)
ereport(FATAL,
(errcode_for_file_access(),
errmsg("could not redirect stdout: %m")));
fflush(stderr);
- if (dup2(syslogPipe[1], fileno(stderr)) < 0)
+ if (dup2(syslogPipe[1], STDERR_FILENO) < 0)
ereport(FATAL,
(errcode_for_file_access(),
errmsg("could not redirect stderr: %m")));
fflush(stderr);
fd = _open_osfhandle((intptr_t) syslogPipe[1],
_O_APPEND | _O_BINARY);
- if (dup2(fd, _fileno(stderr)) < 0)
+ if (dup2(fd, STDERR_FILENO) < 0)
ereport(FATAL,
(errcode_for_file_access(),
errmsg("could not redirect stderr: %m")));
close(fd);
- _setmode(_fileno(stderr), _O_BINARY);
+ _setmode(STDERR_FILENO, _O_BINARY);
/*
* Now we are done with the write end of the pipe.