🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Rick Mon, 27 Jun 1994 06:29
Is poll() broken?
#120
Author: Rick
Date: Mon, 27 Jun 1994 06:29
60 lines
2560 bytes
In the process of bringing expect up on a Pyramid (OSx256MN 5.1a-92a054
1001n MIS-12/07) it appears that poll() doesn't seem to work as
expected.  The relevant section of the manual and a test program
follow:

--------------

     If none of the defined events have occurred on any selected
     file descriptor, poll waits at least timeout msec for an
     event to occur on any of the selected file descriptors.  On
     a computer where millisecond timing accuracy is not
     available, timeout is rounded up to the nearest legal value
     available on that system.  If the value timeout is 0, poll
     returns immediately.  If the value of timeout is -1, poll
     blocks until a requested event occurs or until the call is
     interrupted.  Poll is not affected by the O_NDELAY flag.

--------------

#include <stdio.h>
#include <stropts.h>
#include <poll.h>

main()
{
	struct pollfd fds[5];
	unsigned long nfds;
	int timeout, cc;
	char	buf[80];

	fds[0].fd = 0;
	fds[0].events = POLLIN;
	nfds = 1;
	timeout = -1;
	printf("polling...\n"); fflush(stdout);
	cc = poll(fds, nfds, timeout);
	printf("poll returned %d\n", cc); fflush(stdout);
}

--------------

Compile (att universe) and run the test program.  According to the
manual page, if I type a line while the program is running, poll()
should return and the program should terminate.  No such luck.  It
appears that poll() only checks the file descriptors once, during entry
into the system call - if I do

	sleep 4 ; ./poll

and type a line before the sleep expires, then poll works as expected -
it detects the line waiting to be read, returns 1, the program exits,
and the shell reads the line I typed.  Typing a line after the poll()
call results in nada.

Any clues?  I'm currently working around it by sucking in select() from
libXll.a, but that's not the optimal solution.  Is there a fix for
this?

Thanks,
Rick.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads