}
/* Let's assemble fd[] with the fds to install in place of stdin/stdout/stderr */
- for (int i = 0; i < 3; i++) {
-
+ for (int i = 0; i < 3; i++)
if (fd[i] < 0)
fd[i] = null_fd; /* A negative parameter means: connect this one to /dev/null */
else if (fd[i] != i && fd[i] < 3) {
fd[i] = copy_fd[i];
}
- }
/* At this point we now have the fds to use in fd[], and they are all above the stdio range, so that
* we have freedom to move them around. If the fds already were at the right places then the specific
* fds are -EBADF. Let's now move them to the right places. This is the point of no return. */
- for (int i = 0; i < 3; i++) {
-
+ for (int i = 0; i < 3; i++)
if (fd[i] == i) {
-
/* fd is already in place, but let's make sure O_CLOEXEC is off */
r = fd_cloexec(i, false);
if (r < 0)
goto finish;
-
} else {
assert(fd[i] > 2);
goto finish;
}
}
- }
r = 0;