Content-Length: 272282 | pFad | http://github.com/postgrespro/postgres/commit/790eaa699e4a9626d8a610ec5844e1fd70d73b4e

4C Check dup2() results in syslogger · postgrespro/postgres@790eaa6 · GitHub
Skip to content

Commit 790eaa6

Browse files
committed
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.
1 parent f2795f8 commit 790eaa6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/backend/postmaster/syslogger.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,8 +210,14 @@ SysLoggerMain(int argc, char *argv[])
210210
close(fileno(stderr));
211211
if (fd != -1)
212212
{
213-
dup2(fd, fileno(stdout));
214-
dup2(fd, fileno(stderr));
213+
if (dup2(fd, fileno(stdout)) < 0)
214+
ereport(FATAL,
215+
(errcode_for_file_access(),
216+
errmsg("could not redirect stdout: %m")));
217+
if (dup2(fd, fileno(stderr)) < 0)
218+
ereport(FATAL,
219+
(errcode_for_file_access(),
220+
errmsg("could not redirect stderr: %m")));
215221
close(fd);
216222
}
217223
}

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/790eaa699e4a9626d8a610ec5844e1fd70d73b4e

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy