util: add new safe_close_above_stdio() wrapper
At various places we only want to close fds if they are not stdin/stdout/stderr, i.e. fds 0, 1, 2. Let's add a unified helper call for that, and port everything over.
This commit is contained in:
@@ -917,8 +917,7 @@ int make_stdio(int fd) {
|
||||
if (dup2(fd, STDERR_FILENO) < 0 && r >= 0)
|
||||
r = -errno;
|
||||
|
||||
if (fd >= 3)
|
||||
safe_close(fd);
|
||||
safe_close_above_stdio(fd);
|
||||
|
||||
/* Explicitly unset O_CLOEXEC, since if fd was < 3, then dup2() was a NOP and the bit hence possibly set. */
|
||||
stdio_unset_cloexec();
|
||||
|
||||
Reference in New Issue
Block a user