mirror of
https://github.com/postgres/postgres.git
synced 2025-04-25 21:42:33 +03:00
Check dup2() results in syslogger
Consistently check the dup2() call results throughout syslogger.c. It's pretty unlikely that they'll error out, but if they do, ereport(FATAL) instead of blissfully continuing on. Spotted by the Coverity scanner.
This commit is contained in:
parent
f2795f8b53
commit
790eaa699e
@ -210,8 +210,14 @@ SysLoggerMain(int argc, char *argv[])
|
||||
close(fileno(stderr));
|
||||
if (fd != -1)
|
||||
{
|
||||
dup2(fd, fileno(stdout));
|
||||
dup2(fd, fileno(stderr));
|
||||
if (dup2(fd, fileno(stdout)) < 0)
|
||||
ereport(FATAL,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not redirect stdout: %m")));
|
||||
if (dup2(fd, fileno(stderr)) < 0)
|
||||
ereport(FATAL,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not redirect stderr: %m")));
|
||||
close(fd);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user