• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
poll and stdin
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: poll and stdin
      • From: Ian Lister <email@hidden>
    • Re: poll and stdin
      • From: "Justin C. Walker" <email@hidden>
  • Prev by Date: Hi,What is QTMpeg?How can I download and use it?
  • Next by Date: Re: poll and stdin
  • Previous by thread: Hi,What is QTMpeg?How can I download and use it?
  • Next by thread: Re: poll and stdin
  • Index(es):
    • Date
    • Thread