poll-syscall

Why does poll keep returning although there is no input?

你离开我真会死。 提交于 2019-11-29 07:25:25
I wrote a small test program to figure out how to talk to poll . I created three files testa , testb , testc and wrote the string hello\n to the first. So, here is my invocation of poll : poll(polls.data(),polls.size(),-1) According to the manpage, a timeout of -1 should indicate that the syscall never times out. However, it keeps returning without having anything to read. I always consume one byte of the input and can see the hello\n being printed, but poll doesn't stop there. It just keeps on pretending there to be something to read. #include <sys/types.h> #include <sys/stat.h> #include <sys

Why does poll keep returning although there is no input?

北城余情 提交于 2019-11-28 01:13:28
问题 I wrote a small test program to figure out how to talk to poll. I created three files testa , testb , testc and wrote the string hello\n to the first. So, here is my invocation of poll : poll(polls.data(),polls.size(),-1) According to the manpage, a timeout of -1 should indicate that the syscall never times out. However, it keeps returning without having anything to read. I always consume one byte of the input and can see the hello\n being printed, but poll doesn't stop there. It just keeps

How to handle the Linux socket revents POLLERR, POLLHUP and POLLNVAL?

送分小仙女□ 提交于 2019-11-27 19:10:48
问题 I'm wondering what should be done when poll set these bits? Close socket, ignore it or what? 回答1: A POLLHUP means the socket is no longer connected. In TCP, this means FIN has been received and sent. A POLLERR means the socket got an asynchronous error. In TCP, this typically means a RST has been received or sent. If the file descriptor is not a socket, POLLERR might mean the device does not support polling. For both of the conditions above, the socket file descriptor is still open, and has