[LTP] [PATCH v3 1/9] syscalls: Add epoll_create03

Petr Vorel pvorel@suse.cz
Thu Jul 9 16:56:29 CEST 2026


> Hi!
> > > +static void setup(void)
> > > +{
> > > +	int fd;
> > > +
> > > +	variant_info();
> > > +
> > > +	maxfds = SAFE_SYSCONF(_SC_OPEN_MAX);
> > > +	fds = SAFE_MALLOC(maxfds * sizeof(int));
> > > +	memset(fds, -1, maxfds * sizeof(int));
> > > +
> > > +	fds[0] = SAFE_OPEN("dummy", O_RDWR | O_CREAT, 0700);
> > > +	nfds = 1;
> > > +
> > > +	for (int i = 1; i < maxfds; i++) {
> > > +		fd = dup(fds[0]);
> > > +		if (fd == -1)
> > > +			break;
> > > +		fds[nfds++] = fd;
> > > +	}

> > How many files are created is done via `ulimit -n`, right? (not sure if there
> > is file for it in /proc/sys).

> It's not about created files. There is a per-process limit on the number
> of file descriptors. That can be accessed either via sysconf() or via
> rlimit() and the values are also exported into /proc/$PID/limits.

> > Would it be worth we check that? Or at least check that at least 2 files were
> > opened? Maybe this check should be rather put into dup03.c.

> I guess that it would make more sense to put such check into dup03.c.

OK, let's ignore it.

> However we would have to scan the whole file descriptor table first to
> check on how many fds are already open.

> Something as;

> 	int used_fds = 0;

> 	for (i = 0; i < maxfds; i++) {
> 		if (fcntl(i, F_GETFD) != -1)
> 			used_fds++;
> 	}

> Then we can expect that the limit for the test is maxfds - used_fd

+1

I'll try to add it either into my TODO list or to the issues.

Kind regards,
Petr


More information about the ltp mailing list