Questions tagged [poll-syscall]

poll() performs a similar task to select(): it waits for one of a set of file descriptors to become ready to perform I/O.

18 questions
24
votes
4 answers

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

I'm wondering what should be done when poll set these bits? Close socket, ignore it or what?
user3790882
  • 263
  • 1
  • 2
  • 5
9
votes
3 answers

POLLHUP vs POLLNVAL, or what is POLLHUP?

The manpages say for poll(2): POLLHUP - Hang up (output only) POLLNVAL - Invalid request: fd not open (output only) What exactly is the difference? Writing a simple program shows that POLLNVAL will trigger if I close a file descriptor, then try…
Lycus
  • 410
  • 1
  • 6
  • 15
8
votes
1 answer

How can I use poll to accept multiple clients? (TCP Server) (C)

This polling business seems like it was written by a madman, and I am unsure how to use it to allow for multiple clients to connect to a server and then send their input to all other clients. So if I want to have three clients going, I will need…
countofmontecristo
  • 381
  • 3
  • 5
  • 15
5
votes
3 answers

Why does poll keep returning although there is no input?

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…
bitmask
  • 32,434
  • 14
  • 99
  • 159
2
votes
0 answers

POLLERR with netlink sockets

I am using netlink sockets for user space to kernel space communication. In one of cases, recvmsg call fails with errno 105 which is ENOBUFS and then POLLERR is set on the fd. After this there cannot be any more data flow between the user space and…
lokesharo
  • 305
  • 2
  • 11
2
votes
1 answer

poll not returning even there is change in GPIO FD

I am trying to read a GPIO value using whenever it changes the state. /sys/class/gpio/gpio499/value I have set /sys/class/gpio/gpio499/edge to be both I am trying to monitor the change in value using poll command in one separate thread. Here is…
Kumara
  • 301
  • 1
  • 3
  • 10
2
votes
0 answers

Pollfd structure being accessed while poll() system call in progress

I have a dedicated polling thread that does the poll() system call. On an event a worker thread is posted to do actual read/write from the network. The polling thread disables the fd for an event if it is being worked upon by the worker thread. Once…
siri
  • 123
  • 1
  • 13
1
vote
1 answer

Delete fd from waiting pollfd set concurrently with poll() running

I'm monitoring list of socket fds and wait POLLIN events. First I add fds to array and run poll() on this array. Further, in some cases I want to delete fd from this array(without closing). And sometimes it may occurs concurrently with poll() was…
adanos911
  • 11
  • 2
1
vote
1 answer

Read() after poll returns POLLIN and POLLERR

I have an aysnc threadpool model for my network connection management. A single dispatcher thread that keeps calling poll() and a worker thread pool that either read/write once poll() indicates so. Consider a case where poll() indicates a socket is…
siri
  • 123
  • 1
  • 13
0
votes
1 answer

recv call returns 0 vs POLLHUP event in C poll

(In C socket programming, using poll to manage the fd's and its events) With a data stream socket returned from an accept() call, what's the difference between the event POLLHUP and getting 0 when calling recv(fd, ...) ? They both seem to indicate…
carce-bo
  • 480
  • 2
  • 10
0
votes
1 answer

How to port "select" to "poll" for third error data?

I have the following code that uses select: fd_set fdsu; FD_ZERO(&fdsu); FD_SET(fd, &fdsu); fd_set efds = fdsu; fd_set dfds = fdsu; while (1) { select(cameraUSBP.fd + 1, NULL, &dfds, &efds, NULL); if (FD_ISSET(cameraUSBP.fd, &efds)) { …
gregoiregentil
  • 1,793
  • 1
  • 26
  • 56
0
votes
1 answer

check revents into struct pollfd

According to man(2) poll: int poll(struct pollfd *fds, nfds_t nfds, int timeout); struct pollfd { int fd; /* file descriptor */ short events; /* requested events */ short revents; /* returned events */ }; If I write…
MicrosoctCprog
  • 460
  • 1
  • 3
  • 23
0
votes
1 answer

How to force poll() to error

I am trying to test a scenario in my code when poll() returns an error. But I don't know how to force poll() to return an error. I tried to make poll() block indefinitely and try to send it a SIGINT but that simply stops the process. Is there a way…
siri
  • 123
  • 1
  • 13
0
votes
1 answer

Is it possible for network write() to fail but poll() doesn't detect

Is it possible that a write() call on a socket has failed but the poll() doesn't detect any error? Are there any category of errors that can cause the write to fail but are not considered an error by the poll() system call? I have a dispatcher…
siri
  • 123
  • 1
  • 13
0
votes
1 answer

Can poll() return POLLIN event even after peer hung up?

I see that the poll() system call returns the POLLIN event even after the socket has been closed by the peer. I see both POLLIN and POLLERR set. And this continues to happen even after the read() call has returned -1. My logic handles POLLERR only…
siri
  • 123
  • 1
  • 13
1
2