diff options
Diffstat (limited to 'gl/getdtablesize.c')
| -rw-r--r-- | gl/getdtablesize.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/gl/getdtablesize.c b/gl/getdtablesize.c index b98fbb70..cc823952 100644 --- a/gl/getdtablesize.c +++ b/gl/getdtablesize.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* getdtablesize() function: Return maximum possible file descriptor value + 1. | 1 | /* getdtablesize() function: Return maximum possible file descriptor value + 1. |
| 2 | Copyright (C) 2008-2025 Free Software Foundation, Inc. | 2 | Copyright (C) 2008-2026 Free Software Foundation, Inc. |
| 3 | Written by Bruno Haible <bruno@clisp.org>, 2008. | 3 | Written by Bruno Haible <bruno@clisp.org>, 2008. |
| 4 | 4 | ||
| 5 | This file is free software: you can redistribute it and/or modify | 5 | This file is free software: you can redistribute it and/or modify |
| @@ -61,13 +61,10 @@ getdtablesize (void) | |||
| 61 | { | 61 | { |
| 62 | /* We are looking for the number N such that the valid file descriptors | 62 | /* We are looking for the number N such that the valid file descriptors |
| 63 | are 0..N-1. It can be obtained through a loop as follows: | 63 | are 0..N-1. It can be obtained through a loop as follows: |
| 64 | { | 64 | for (int fd = 3; fd < 65536; fd++) |
| 65 | int fd; | 65 | if (dup2 (0, fd) == -1) |
| 66 | for (fd = 3; fd < 65536; fd++) | 66 | break; |
| 67 | if (dup2 (0, fd) == -1) | 67 | return fd; |
| 68 | break; | ||
| 69 | return fd; | ||
| 70 | } | ||
| 71 | On Windows XP, the result is 2048. | 68 | On Windows XP, the result is 2048. |
| 72 | The drawback of this loop is that it allocates memory for a libc | 69 | The drawback of this loop is that it allocates memory for a libc |
| 73 | internal array that is never freed. | 70 | internal array that is never freed. |
