Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2012-02-01 21:20:02 +0400
committerChristopher Faylor <me@cgf.cx>2012-02-01 21:20:02 +0400
commit8fa8b3a3891165dc4c8eb8f05923a3352b20aec3 (patch)
tree999711e4be4cb1ba45294c113a1741f8263dfde4 /winsup/cygwin/syscalls.cc
parent4c68bf65c8b225f96c4cea4417ffd3a0dd0341e4 (diff)
* dtable.cc (dtable::dup_worker): Add comment explaining why refcnt isn't
incremented here. (dtable::dup3): Simplify slightly. Add comment. * syscalls.cc (dup3): Increment refcnt here, similarly to dup2.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 4ff64a3e3..3ed0f4f95 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -161,8 +161,9 @@ dup3 (int oldfd, int newfd, int flags)
set_errno (cfd < 0 ? EBADF : EINVAL);
res = -1;
}
- else
- res = cygheap->fdtab.dup3 (oldfd, newfd, flags);
+ else if ((res = cygheap->fdtab.dup3 (oldfd, newfd, flags)) == newfd)
+ cygheap->fdtab[newfd]->refcnt (1);
+
syscall_printf ("%R = dup3(%d, %d, %p)", res, oldfd, newfd, flags);
return res;
}