Skip to content

Commit 2d7da9a

Browse files
JawsKimpevik
authored andcommitted
open: replace getdtablesize with getrlimit
The test currently uses getdtablesize() to determine the maximum number of file descriptors for the process. This interface is considered legacy and is not specified by POSIX. Use getrlimit() instead, which provides a well-defined and portable way to obtain the per-process file descriptor limit. Link: https://lore.kernel.org/ltp/20260219141532.6513-2-always.starving0@gmail.com/ Reviewed-by: Petr Vorel <pvorel@suse.cz> Signed-off-by: Jinseok Kim <always.starving0@gmail.com>
1 parent 2a7242a commit 2d7da9a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

testcases/kernel/syscalls/open/open04.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ static char fname[20];
2222
static void setup(void)
2323
{
2424
int fd;
25+
struct rlimit rlim;
2526

26-
fds_limit = getdtablesize();
27+
SAFE_GETRLIMIT(RLIMIT_NOFILE, &rlim);
28+
fds_limit = rlim.rlim_cur;
2729
first = SAFE_OPEN(FNAME, O_RDWR | O_CREAT, 0777);
2830

2931
fds = SAFE_MALLOC(sizeof(int) * (fds_limit - first));

0 commit comments

Comments
 (0)