poll and stdin
poll and stdin
- Subject: poll and stdin
- From: Michael Tuexen <email@hidden>
- Date: Tue, 18 Apr 2006 19:31:46 +0200
Dear all,
file descriptor 0 (for stdin) can be used in the poll system call on
Panther, but on Tiger poll immediately returns with revents=POLLNVAL.
The following program show the difference when running on Panther and
Tiger.
On Panther it poll times out every 1000ms and if you enter something
poll returns and read reads the input.
In Tiger, poll immediately returns and you call read which blocks.
Is it a feature or a bug of Tiger that poll() does not support stdin?
Best regards
Michael
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include <stdio.h>
#include <poll.h>
#define BUFFERSIZE 1024
int main()
{
struct pollfd input;
char buffer[BUFFERSIZE];
int n, m;
input.fd = 0;
input.events = POLLIN | POLLPRI;
input.revents = 0;
while (1) {
n = poll(&input, 1, 1000);
printf("poll returned with result = %d and revents = %d.\n",
n, input.revents);
if (n > 0) {
m = read(0, buffer, sizeof(buffer));
printf("read returned %d.\n", m);
if (m == 0)
break;
}
}
return 0;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden