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>2013-12-05 23:43:34 +0400
committerChristopher Faylor <me@cgf.cx>2013-12-05 23:43:34 +0400
commit09244c002e00fe24571c50d249bc649694fb1837 (patch)
treee8d67283584d7ad72fac50e7730eb886726b56ec /winsup/cygwin/syscalls.cc
parent2f8a6f194746751fbfe8ba2fef483e8bc371ba29 (diff)
* cygheap.h (cygheap_fdnew): Avoid setting errno directly since it will have
been set by a previous function. * dtable.h (dtable::extend): Accept second size_t argument. * dtable.cc (dtable::extend): Accept second "min" argument which allows checking for OPEN_MAX_MAX boundary conditions. (dtable_init): Accommodate second argument to dtable::extend. (dtable::find_unused_handle): Ditto. * syscalls.cc (setdtablesize): Ditto. (dup): Return any error passed by cygheap_fdnew() directly. (getdtablesize): Just return dtable size directly.
Diffstat (limited to 'winsup/cygwin/syscalls.cc')
-rw-r--r--winsup/cygwin/syscalls.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 8769eb582..cb9709165 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -120,7 +120,12 @@ close_all_files (bool norelease)
extern "C" int
dup (int fd)
{
- int res = cygheap->fdtab.dup3 (fd, cygheap_fdnew (), 0);
+ int res;
+ int newfd = cygheap_fdnew ();
+ if (newfd < 0)
+ res = -1;
+ else
+ res = cygheap->fdtab.dup3 (fd, newfd, 0);
syscall_printf ("%R = dup(%d)", res, fd);
return res;
}
@@ -2611,7 +2616,8 @@ setdtablesize (int size)
return -1;
}
- if (size <= (int)cygheap->fdtab.size || cygheap->fdtab.extend (size - cygheap->fdtab.size))
+ if (size <= (int) cygheap->fdtab.size
+ || cygheap->fdtab.extend (size - cygheap->fdtab.size, OPEN_MAX_MAX))
return 0;
return -1;
@@ -2620,7 +2626,7 @@ setdtablesize (int size)
extern "C" int
getdtablesize ()
{
- return cygheap->fdtab.size > OPEN_MAX ? cygheap->fdtab.size : OPEN_MAX;
+ return cygheap->fdtab.size;
}
extern "C" int