Domanda

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.

È stato utile?

Soluzione

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.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top