Вопрос

This post:

Empty or "flush" a file descriptor without read()?

, says that it is possible to do a lseek() on a fd you don't want to read from, thereby avoiding unnecessary copying, but this does not apply to fds I create with timerfd_create(). Why is this so and does there exist a workaround (except to use read(), which works).

I try to do lseek() like this:

lseek(fd, 0, SEEK_END);

And strerror() returned Illegal seek. Again, read(fd, buffer, 8) works.

Это было полезно?

Решение

timer_fds are not seekable. Not every fd is. Use read to read the relevant bytes.

Note that contrary to the POSIX tag, these calls are Linux specific. From the man page:

CONFORMING TO
       These system calls are Linux-specific.
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top