What is the advantage of using epoll_create1 () instead of epoll_create ()

I am rewriting a multi-threaded Linux-2.6.32 + application to replace selectwith epoll.

The manual pages for epoll_create1 (2) declare that:

If the flags are 0, then, in addition to the obsolete argument being discarded, epoll_create1 () is the same as epoll_create ().

However, not this obsolete size argument used in epoll_wait(2)how maxevents?

epoll_wait(int epfd, struct epoll_event *events,
                  int maxevents, int timeout);

This means that when using epoll we can avoid declaring the maximum number of events in epoll_create1, but sooner or later will we have to refer to it when called epoll_wait? If so, what is the point of bringing epoll_create1into the game?

Thank you for enlightening me on this.

+5
source share
2 answers

No, epoll_waitit maxeventstells you the maximum number of events to be returned. This has nothing to do with how many of them are supported in the kernel.

Older versions epoll_createused size to set certain restrictions, but it was no longer used, so the comment that the argument is sizedeprecated.

The advantage of using it epoll_create1is that it allows you to specify flags that, it seems to me, are currently limited to closing-exec (so that the file descriptor automatically closes when execanother process is running).

+6
source

epoll_create1() . .

:/fs/eventpoll.c

SYSCALL_DEFINE1(epoll_create, int, size)
{
    if (size <= 0)
        return -EINVAL;

    return sys_epoll_create1(0);
}

epoll_wait() max_events fd, fd eventpoll struct

+1