public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
* [PATCH] Cygwin: getdtablesize: always return OPEN_MAX_MAX
@ 2021-01-28  2:51 Ken Brown
  2021-01-28 10:20 ` Corinna Vinschen
  0 siblings, 1 reply; 11+ messages in thread
From: Ken Brown @ 2021-01-28  2:51 UTC (permalink / raw)
  To: cygwin-patches

According to the Linux man page for getdtablesize(3), the latter is
supposed to return "the maximum number of files a process can have
open, one more than the largest possible value for a file descriptor."
The constant OPEN_MAX_MAX is the only limit enforced by Cygwin, so we
now return that.

Previously getdtablesize returned the current size of cygheap->fdtab,
Cygwin's internal file descriptor table.  But this is a dynamically
growing table, and its current size does not reflect an actual limit
on the number of open files.

With this change, gnulib now reports that getdtablesize and
fcntl(F_DUPFD) work on Cygwin.  Packages like GNU tar that use the
corresponding gnulib modules will no longer use gnulib replacements on
Cygwin.
---
 winsup/cygwin/syscalls.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 5da05b18a..1f16d54b9 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -2887,7 +2887,7 @@ setdtablesize (int size)
 extern "C" int
 getdtablesize ()
 {
-  return cygheap->fdtab.size;
+  return OPEN_MAX_MAX;
 }
 
 extern "C" int
-- 
2.30.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-02-01 10:46 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-28  2:51 [PATCH] Cygwin: getdtablesize: always return OPEN_MAX_MAX Ken Brown
2021-01-28 10:20 ` Corinna Vinschen
2021-01-28 13:42   ` Ken Brown
2021-01-28 16:07     ` Corinna Vinschen
2021-01-28 16:13       ` Corinna Vinschen
2021-01-28 22:28         ` Ken Brown
2021-01-29 19:23           ` Ken Brown
2021-02-01  9:42             ` Corinna Vinschen
2021-01-28 20:33       ` Ken Brown
2021-02-01  9:50         ` Corinna Vinschen
2021-02-01 10:46           ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).