newfd
int newfd = dup2( hc->conn_fd, STDERR_FILENO + 1 );
if ( newfd >= 0 )
hc->conn_fd = newfd;
int ret, oerrno, newfd;
newfd = fd;
if (fd < 0 && (newfd = open(path, O_RDONLY | O_DIRECTORY |
if (fstat(newfd, &sb)) {
ret = fchdir(newfd);
(void)close(newfd);
dup2_fd(int oldfd, int newfd, int flags, bool kernel)
TRACE(("dup2_fd: ofd = %d, nfd = %d\n", oldfd, newfd));
if (oldfd < 0 || newfd < 0)
|| (uint32)newfd >= context->table_size
if (oldfd != newfd) {
TFD(Dup2FD(context, oldfd, newfd));
evicted = context->fds[newfd];
select_info* selectInfos = context->select_infos[newfd];
context->select_infos[newfd] = NULL;
context->fds[newfd] = context->fds[oldfd];
fd_set_close_on_exec(context, newfd, (flags & O_CLOEXEC) != 0);
fd_set_close_on_fork(context, newfd, (flags & O_CLOFORK) != 0);
return newfd;
int newfd;
newfd = -1;
newfd =
if (newfd < 0)
int newfd = dup(action->fd);
if (newfd == -1)
fcntl(newfd, F_SETFD, FD_CLOEXEC);
*errfd = newfd;
dup2_fd(int oldfd, int newfd, bool kernel)
TRACE(("dup2_fd: ofd = %d, nfd = %d\n", oldfd, newfd));
if (oldfd < 0 || newfd < 0)
|| (uint32_t)newfd >= context->table_size
if (oldfd != newfd) {
evicted = context->fds[newfd];
context->fds[newfd] = context->fds[oldfd];
fd_set_close_on_exec(context, newfd, false);
return newfd;