Cartesius00
Cartesius00

Reputation: 24414

Epoll on regular files

Can epoll (on Linux) be somehow useful for regular files? I know it's primarily used with sockets but just wonder.

Upvotes: 32

Views: 13280

Answers (2)

osgx
osgx

Reputation: 94465

I think, it will fail at epoll_ctl with EPERM:

   EPERM  The target file fd does not support epoll.

if the file has no poll() interface.

The actual code is http://lxr.linux.no/#linux+v3.1/fs/eventpoll.c#L1373

1373    /* The target file descriptor must support poll */
1374        error = -EPERM;
1375        if (!tfile->f_op || !tfile->f_op->poll)
1376                goto error_tgt_fput;
1377

Upvotes: 24

user149341
user149341

Reputation:

Not really. epoll only makes sense for file descriptors which would normally exhibit blocking behavior on read/write, like pipes and sockets. Normal file descriptors will always either return a result or end-of-file more or less immediately, so epoll wouldn't do anything useful for them.

Upvotes: 30

Related Questions